我怎样才能重新加载的tableView从类别表中所列RootViewController的? [英] How can I reload the tableView that listed in RootViewController from a category table?
问题描述
我在做一个笑话应用程序。主页是在 RootViewController的
上市从类别表类别列表。
I'm doing a joke app. The home page is list of categories that listed in RootViewController
from a category table.
当用户进行修改更新数据库。问题是,当我回来的主页,该表是不刷新。
当我再次运行应用程序的变化是可见的。
The database is updated when the user performs changes. The problem is when I come back to the home page, the table is not refreshed. Changes are visible when I run the app again.
我试过 [的tableView reloadData]
和 [self.tableView reloadData]
,但没有结果。
I tried [tableView reloadData]
and [self.tableView reloadData]
but with no result.
在这里,code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
WhySoSeriousAppDelegate *appDelegate = (WhySoSeriousAppDelegate *)[[UIApplication sharedApplication] delegate];
return appDelegate.jokes.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier ] autorelease];
UIView *activeColor = [[[UIView alloc] init] autorelease];
activeColor.backgroundColor = [UIColor colorWithRed:170/256.0 green:50/256.0 blue:0/256.0 alpha:1.0];
cell.selectedBackgroundView = activeColor;
}
WhySoSeriousAppDelegate *appDelegate = (WhySoSeriousAppDelegate *)[[UIApplication sharedApplication] delegate];
Joke *joke = (Joke *)[appDelegate.jokes objectAtIndex:indexPath.row];
[cell setText:joke.category];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
我该如何解决这个问题呢?
How can I solve the problem?
推荐答案
刷新无论是在应用程序委托李冰冰的数据在同一个控制器看到更改的记录。然后重新加载表视图。
Reload the Joke data either in app delegate on in same controller to see the changed records. And then reload the table view.
这篇关于我怎样才能重新加载的tableView从类别表中所列RootViewController的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!