在.h文件:如何使用alertview刷新uitableivew?
@property (weak, nonatomic) IBOutlet UITableView *tableView;
在.m文件:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"RememberedTableListCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [[listItems objectAtIndex:indexPath.row] objectForKey:@"word"];
return cell;
}
- (IBAction)resetList:(UIBarButtonItem *)sender {
UIAlertView *resetAlert = [[UIAlertView alloc] initWithTitle:@"Reset" message:@"Are you sure to reset the list?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[resetAlert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
// the user clicked Yes
if (buttonIndex == 1) {
// reset the list
//reload table data
NSLog(@"button yes is clicked");
for (NSMutableDictionary*l in listAll) {
[l setValue:@"0" forKey:@"remembered"];
}
[self.tableView reloadData];
//[[NSOperationQueue mainQueue]addOperationWithBlock:^{[self.tvRemembered reloadData];}];
//[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForSelectedRows] withRowAnimation:UITableViewRowAnimationNone];
NSLog(@"refreshing...");
}
}
如何刷新的UITableView與UIAlertView中代表?我已經嘗試reloadData:
和reloadRowsAtIndexPaths:
像上面那樣。但他們沒有幫助。任何幫助將不勝感激。
您是否記錄過buttonIndex之一的任何語句? –
是的,我沒有,沒關係。 – tipsywacky
你能提供'alertView'的代碼嗎? –