Search code examples
objective-ciosxcode4

How to reload a view in a TabBar controller?


I have a UITableView that I use to send an email using MFMailComposeViewController. It displays the data correctly the first time. If I send or cancel the email, I get a blank screen from that point forward (in other words, I can't send email again).

When I come back to the view to send an email again, it's blank, therefore the view needs to be re-loaded as it originally was.

What do I have to do to fix this? (I'm using XCode4 with Storyboards and ARC).


Solution

  • Misused API: When using a UITabBarController, viewDidLoad is only called once at the beginning of the load of the view. Therefore, when you put code in viewDidLoad, it only gets executed once. By moving that code to viewWillAppear, it gets loaded each time.