下面是我删除的代码,它工作正常,但您必须打开另一个选项卡,然后再次单击此选项卡才能移除该项目。因为这不是普通的UITableView,所以你不能从数组中移除然后更新表。所以有人可以帮助我刷新视图。另外下面的代码片段不起作用:从UITableView删除行
// Reload the view completely
if ([self isViewLoaded]) {
self.view=nil;
[self viewDidLoad];
}
这里是我的删除代码:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete){
// Delete song from list & disc \\
//Remove from arrays
[self.Writer removeObjectAtIndex:[indexPath row]];
[self.Book removeObjectAtIndex:[indexPath row]];
[self.BookImageId removeObjectAtIndex:[indexPath row]];
NSString *TempWriter = [self.ArtistNamesArray componentsJoinedByString:@","];
NSString *TempBook = [self.SongNamesArray componentsJoinedByString:@","];
NSString *TempBookImageId = [self.YoutubeIDSArray componentsJoinedByString:@","];
TempWriter = [TempWriter substringToIndex:[TempArtistNames length] - 1];
TempBook = [TempBook substringToIndex:[TempSongNames length] - 1];
TempBookImageId = [TempBookImageId substringToIndex:[TempYouTube length] - 1];
//Save Details
[[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%@,", TempBook] forKey:@"BookName"];
[[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%@,", TempWriter] forKey:@"WriterName"];
[[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%@,", TempBookImageId] forKey:@"ImageId"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
和我的viewWillAppear中的代码是:
- (void) viewWillAppear: (BOOL) animated
{
// Reload the view completely
if ([self isViewLoaded]) {
self.view=nil;
[self viewDidLoad];
}
}
感谢所有谁可以帮助
完全正是我想要的:)干杯兄弟 – user393273 2011-03-27 17:57:16