我有任何数量的单个数组。我想在不同的部分划分为7的倍数。我无法得到这个工作。这是一个2个元素的例子。如何在节中操作数组?
- (void)viewDidLoad {
[super viewDidLoad];
array =[NSMutableArray arrayWithObjects:@"d",@"s",@"a",@"qq",@"dqd",@"dqq",@"qdqdf",@"dqdfqf", nil];
// Do any additional setup after loading the view from its nib.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return ceil(array.count/2.0); // round up the floating point division
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger sections = [self numberOfSectionsInTableView:tableView];
if (section == sections - 1) {
NSInteger count = array.count & 2;
if (count == 0) {
count = 2;
}
return count;
} else {
return 2;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
// cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
@rmaddy请帮助这项工作 –
发布答案后不要完全改变你的问题。它使答案毫无价值。 – rmaddy