use*_*273 1 iphone objective-c uitableview viewwillappear
这是我删除的代码,它工作正常,但您必须打开另一个选项卡,然后再次单击此选项卡以删除项目.由于这不是普通的UITableView,你不能只从数组中删除然后更新表.所以有人可以帮我刷新视图.此外,下面的代码段不起作用:
// Reload the view completely
if ([self isViewLoaded]) {
self.view=nil;
[self viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)
这是我的删除代码:
- (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];
}
}
Run Code Online (Sandbox Code Playgroud)
我的ViewWillAppear代码是:
- (void) viewWillAppear: (BOOL) animated
{
// Reload the view completely
if ([self isViewLoaded]) {
self.view=nil;
[self viewDidLoad];
}
}
Run Code Online (Sandbox Code Playgroud)
感谢所有有帮助的人
归档时间: |
|
查看次数: |
11565 次 |
最近记录: |