我有以下代码创建我的应用程序的设置视图。但是当我滚动时,底部部分被第1部分(包含图像的一个单元格)取代,有什么建议?我尝试了很多东西(特别是dequeueReusableCellWithIdentifier),但都没有成功。ios - UITableView重复单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
simpleCell *cell = (simpleCell *)[self.tableview dequeueReusableCellWithIdentifier:@"simple" forIndexPath:indexPath];
cell.imageView.image = nil;
cell.text.text = nil;
//cell = [[simpleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"simple"];
if(indexPath.row == 0){
cell.text.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:13];
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"isFacebookLoggegIn"]){
cell.imageView.image = [UIImage imageNamed:@"fb_tbl_connect.png"];
}else{
cell.imageView.image = [UIImage imageNamed:@"tbl_disconnect_fb.png"];
}
}
if(indexPath.row == 1){
cell.text.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:13];
cell.text.text = @"Edit Your Profile";
}
return cell;
}
if (indexPath.section == 1) {
simpleCell *cell = (simpleCell *)[tableView dequeueReusableCellWithIdentifier:@"simple" forIndexPath:indexPath];
if(indexPath.row == 0){
cell.text.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:13];
cell.text.text = @"Send Feedback";
}
return cell;
}
if (indexPath.section == 2) {
simpleCell *cell = (simpleCell *)[tableView dequeueReusableCellWithIdentifier:@"simple" forIndexPath:indexPath];
if (indexPath.row == 0) {
cell.text.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:13];
cell.text.text = @"Visit Wowpads.com";
}
if (indexPath.row == 1) {
cell.text.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:13];
cell.text.text = @"Terms of Service";
}
}
return 0;
}
}
这是一个错误,我已纠正它。但我的代码仍然不起作用 – Yrol 2014-10-17 09:20:43
你使用heightforrowAtindexpath吗? – 2014-10-17 09:57:38
http://stackoverflow.com/questions/26398924/tableview-sections-overwrite-in-iphone5s-and-greater-versions-只检查它 – 2014-10-17 09:59:59