Updating UIView when selected in TabBar

0 views
Skip to first unread message

Eric Chan

unread,
May 12, 2009, 4:10:26 PM5/12/09
to RTFM: Development for Mobile Devices
So viewDidLoad only runs once and I cant refresh my groceries list (on
tab bar) when I change something on the Menu. I also tried putting a
[table reloadData] in viewWillAppear but apparently that doesn't get
called either when you changed tabs.

Does anyone know what gets called when the user changes tabs from the
tab bar?

-- Eric

DavidK

unread,
May 12, 2009, 4:15:17 PM5/12/09
to RTFM: Development for Mobile Devices
I used viewDidAppear and it worked fine.

Gregory Schmidt

unread,
May 12, 2009, 4:19:18 PM5/12/09
to rtfm-development-...@googlegroups.com
viewWillAppear seems to get called when changing tabs. using NSLog
inside of viewWillAppear shows that. perhaps you aren't updating the
groceries list properly while in the other view?

Nathan Nichols

unread,
May 12, 2009, 4:20:14 PM5/12/09
to rtfm-development-...@googlegroups.com
Eric,

-viewWillAppear should be getting called. Don't forget (I frequently
do) that it takes a BOOL parameter. So you have to declare it like

-(void)viewWillAppear:(BOOL)animated

or it will never get called.

Under the covers, the tab bar controller is doing something like:

if ([newViewController
respondsToSelector(@selector(viewWillAppear:))]) {
[newViewController viewWillAppear:animated];
}

If you forget the parameter, your viewController responds to
@selector(viewWillAppear) but not @selector(viewWillAppear:), so it
won't be called.

Nate

Eric Chan

unread,
May 12, 2009, 5:04:00 PM5/12/09
to RTFM: Development for Mobile Devices
That fixed it. Thanks.

The problem was that I did not declare my viewWillAppear with a BOOL
parameter and although that did not return an error, it did not get
called ever.
Reply all
Reply to author
Forward
0 new messages