iphone refresh viewcontroller not working when app enters foreground
i have an application with 3 tabs inbox,contacts and settings.
In inbox, there is a list of messages from other users ,i update the messages using a function reloadTableViewDataSource
, now i have to reload or refresh the messages when the application enters the foreground.
To achieve this,i have given the 开发者_StackOverflowfollowing code in appdelegate.
- (void)applicationWillEnterForeground:(UIApplication *)application {
application.applicationIconBadgeNumber=0;
Inbox *inbox=[[Inbox alloc]init];
inbox.userid=self.usermail;
inbox.password=self.password;
inbox.loggedInUserId=self.loggedinUserId;
[inbox reloadTableViewDataSource];
}
the updated method seems to be called as i am seeing the nslog
messages about update but nothing is actually happening in the inbox viewcontroller,the new messages coming are not refreshed, what is the correct way to do this ?
It seems to me that you create a new Inbox object and refresh its content. But what you really want is to refresh the data of your Inbox object which is currently displayed.
So what you need to do, is holding a reference to the Inbox object which is used in your ViewController. And invoke reloadTableViewDataSource on that reference.
hope thats the problem...
精彩评论