これが私の削除のコードです。正常に機能しますが、アイテムを削除するには、別のタブを開いてからこのタブをもう一度クリックする必要があります。これは通常の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];
}
}
助けてくれるすべての人に感謝します