我有以下代碼創建我的應用程序的設置視圖。但是當我滾動時,底部部分被第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