我有一个在 mainApp的viewDidLoad上启动的登录。这意味着mainApp 中的numberOfRowsInSection在登录之前运行,并导致我的tableview没有被填充。
我在mainApp的viewWillAppear中有我的 JsonArray 和 reloadData 函数,以使numberOfRowsInSection在登录之后运行。所以我放了:
[self.tableView reloadData];
...在视图中将出现。但这并不能让它在登录后运行。
有什么建议么?
提前致谢。
代码更新
登录页面
if (serverOutput != nil) {
//UIAlertView *alertSuccess = [[UIAlertView alloc] initWithTitle:@"Congrats" message:@"You are authorised" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
//[alertSuccess show];
//[alertSuccess release];
LucentaAppDelegate *appDelegate = (LucentaAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.userProducts = serverOutput;
loginButton.enabled = FALSE;
[self dismissModalViewControllerAnimated:YES];
主视图
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
LucentaAppDelegate *appDelegate = (LucentaAppDelegate *)[[UIApplication sharedApplication] delegate];
self.jsonArray = [appDelegate.userProducts JSONValue];
//[self.tableView reloadData];
[self performSelector:(@selector(refreshDisplay:)) withObject:(tableView) afterDelay:0.5];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Test Alert" message:@"View Will Appear." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
[alert show];
[alert release]; }
-(void)refreshDisplay:(UITableView *)tableView {
[self.tableView reloadData];}