2 つのビュー コントローラーがあり、プロジェクトで sqlite を使用しています。1 つのコントローラーで UITableview を作成して表示し、別のコントローラーで sqlite を介してテーブル セルを削除しています。私の問題は、あるコントローラーから削除操作を行って別のコントローラーに戻るときに、テーブルビューが以前の古いビューと重なってしまうことです。テーブルビューを削除して再作成しました。問題は解決しません。どんな助けでも大歓迎です。スクリーンショットを添付しました。
// create cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSString *cellIdentifier = @"Cell";
MOProfileTablViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if(cell == nil)
{
cell = [[MOProfileTablViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.profileLabel.textColor = [UIColor whiteColor];
[cell.profileLabel setFont: [UIFont fontWithName:kfontNameBold size:18]];
cell.profileNumberLabel.textColor = [UIColor whiteColor];
[cell.profileNumberLabel setFont:[UIFont fontWithName:kFontName size:14]];
}
if(selectedIndex == [indexPath row] && [[sqlExecutObj.result objectAtIndex:1] count] > [indexPath row])
{
self.preSelectedProfileViewCell = cell;
cell.selectionButton.hidden = NO;
}
else
cell.selectionButton.hidden = YES;
if ([[sqlExecutObj.result objectAtIndex:1] count] && [[sqlExecutObj.result objectAtIndex:1] count] > [indexPath row])
{//set cell background color
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[profileColorArray objectAtIndex:indexPath.row]]];
cell.backgroundColor = [UIColor clearColor];
}
else
{
if ([[sqlExecutObj.result objectAtIndex:1] count]== [indexPath row]) {
}else {
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_newprofile.png"]];
cell.backgroundColor = [UIColor clearColor];
}
}
if ([[sqlExecutObj.result objectAtIndex:1] count] && [[sqlExecutObj.result objectAtIndex:1] count] > [indexPath row])
{
cell.profileLabel.text = [[sqlExecutObj.result objectAtIndex:0] objectAtIndex:indexPath.row];
cell.profileNumberLabel.text = [[sqlExecutObj.result objectAtIndex:3] objectAtIndex:indexPath.row]; //settings-icon.png
if ([[[sqlExecutObj.result objectAtIndex:1] objectAtIndex:indexPath.row] isEqualToString:@"default"])
{
[cell.profileImage.layer setBorderWidth:0.0f];
cell.profileImage.image = [UIImage imageNamed:@"group.png"] ;
cell.profileImage.frame = CGRectMake(cell.selectionButton.frame.origin.x+cell.selectionButton.frame.size.width+15,13,30 ,30);
}
else
{
[cell.profileImage.layer setBorderWidth:2.0f];
cell.profileImage.frame = CGRectMake(cell.selectionButton.frame.origin.x+cell.selectionButton.frame.size.width+15,10,30 , 30);
UIImage *imge=[UIImage imageWithData:[NSData dataWithContentsOfFile:[[sqlExecutObj.result objectAtIndex:1]objectAtIndex:indexPath.row]]];
cell.profileImage.image = imge;
}
if ( [ [ [sqlExecutObj.result objectAtIndex:0] objectAtIndex:indexPath.row] isEqualToString:@"PENDING..."] || [ [ [sqlExecutObj.result objectAtIndex:0] objectAtIndex:indexPath.row] isEqualToString:@"New Virtual Number"] ) {
cell.accessoryType =UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.profileLabel setFont:[UIFont fontWithName:kFontName size:16.5]];
} else {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
}
else
{
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if ([[sqlExecutObj.result objectAtIndex:1] count] == [indexPath row]) {
//customizing cell for manage account
cell.profileLabel.text = @"Manage Account";
cell.profileLabel.frame = CGRectMake(cell.profileImage.frame.origin.x+cell.profileImage.frame.size.width+10,12,150,24);
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"settings-bg.png"]]; //settings-icon.png
cell.profileNumberLabel.text = nil;
[cell.profileImage.layer setBorderWidth:0.0f];
cell.profileImage.image = [UIImage imageNamed:@"settings-icon.png"] ;
cell.profileImage.frame = CGRectMake(cell.selectionButton.frame.origin.x+cell.selectionButton.frame.size.width+15,10,30 ,30);
[cell.profileLabel setFont:[UIFont fontWithName:kFontName size:18]];
cell.profileLabel.textColor = [UIColor whiteColor];
}
else
{
//customizing cell for add-new-profile cell
cell.profileLabel.text = nil;
cell.profileNumberLabel.text = nil;
cell.profileImage.image = nil;
[cell.profileLabel setFont:[UIFont fontWithName:kFontName size:20]];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
}
return cell;
}