Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-12-2011, 01:21 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 48
cybohemia is on a distinguished road
Default Notification callback from BACK button in TableView of SplitViewController

I am using a UISplitViewController and I would like to change the view in the DetailArea when the user navigates through different levels in the associated TableView.

Going down a level is easy - when the user selects a row, I can change the view through the didSelectRow: notification.

However, when the user hits the "Back" button in the navigation bar to return to the previous table, I don't know how to get the notification and so don't know when to change the DetailView.

On the iPhone, such a notification wouldn't be needed since there is no split view. However, on an iPad, such a notification would be useful but I'm not sure how to access it or even if it exists.

Has anyone been able to figure out how to respond when a user hits the back button at the navigation bar on top of a table view?

Thanks.
cybohemia is offline   Reply With Quote
Old 04-12-2011, 01:58 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

You have 3 options:
- Use a custom back button and use its action to do what you need (you'll need to use your own graphics if you want the arrow shape of the standard back button)
- Use viewWillDisappear and keep state when you are disappearing forward (didSelect) and backwards (back button)
- If you must really intercept the standard back button and sometimes denying the ability to go back, you must subclass UINavigationController and override navigationBar:shouldPopItem: . I do this to query my controllers if the user is allowed to go back at some places (i.e when they have unsaved changes on the detail view I ask for permission at first before letting they go back)
nobre84 is offline   Reply With Quote
Old 04-12-2011, 07:29 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 48
cybohemia is on a distinguished road
Default

Thanks for the suggestions, nobre84.

I was hoping for the 2nd option so that I wouldn't have to subclass the navigation controller as it is implicitly defined for table views (and automatically takes care of changing the label for the back button to reflect the name of the previous table).

But viewWillDisappear doesn't actually get invoked when a user simply presses the back button on the top of a table view since the table view itself doesn't actually disappear - only its data gets updated.

So I guess I will need to customize things...dang!

Quote:
Originally Posted by nobre84 View Post
You have 3 options:
- Use a custom back button and use its action to do what you need (you'll need to use your own graphics if you want the arrow shape of the standard back button)
- Use viewWillDisappear and keep state when you are disappearing forward (didSelect) and backwards (back button)
- If you must really intercept the standard back button and sometimes denying the ability to go back, you must subclass UINavigationController and override navigationBar:shouldPopItem: . I do this to query my controllers if the user is allowed to go back at some places (i.e when they have unsaved changes on the detail view I ask for permission at first before letting they go back)
cybohemia is offline   Reply With Quote
Reply

Bookmarks

Tags
back, ipad, notification, uisplitviewcontroller, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 360
12 members and 348 guests
dansparrow, dre, ilmman, LezB44, Nobbsy, Objective Zero, oztemel, samdanielblr, shagor012, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0