1

Say I have UITableViewController A, and UITableViewController B. Both A and B loads UIView C. At the back button in C, how do I make sure it always goes back to B, rather than where it came from?

Here is a concrete example: A=Contacts window in iphone skype. B=Chats window, each row is a chat history with a different person C = Chat window displays a conversation with the same person .

C can be loaded from A or B, but I want the backbutton on the Chat window ( C ) goes back to Chats (B) window only.

Cheers.

Michael Z
  • 4,534
  • 4
  • 21
  • 27

4 Answers4

2

Your going to find this hard to implement largely because this is a bad UI design and the API does not support it.

You user will expect a back button to take them "back" to the previous view just as in every other app they use. Going to any other view will confuse them all the more so because it isn't a hierarchy but a loop. Users will sometimes go B-->C-->B but other times, A-->C-->B-->C. (How do they get back to A?)

Instead of a back button in C, you should have a button on the right hand side that always takes you to B regardless of how you got to C. The same button in the same context should always produce the same result. Users shouldn't have to remember what invisible mode they are in to predict what action a button will have.


Edit01:(Response to comments below)

(This is all off the top of my head so take it with a grain of salt.) You will need to abandon using the navigation controller and instead manage the views yourself. You will need to swap the views out via the tabbar by substituting the C view for the A and B views in each tab's view property.

I think you will have to start with master view that is invisible and then add the tabbar to that. In the master view controller, create attributes/outlets for each view. In each view, have an attribute/outlet linked to the master view controller. Then have the "back button" (which I strongly suggest you label "Chats") of C view call method in A and B that then calls a method in the master view controller that (1)removes the C view from either tab A or tab B (2) switches the tab to the B tab and then (3) loads view B into tab B.

I can't emphasis how ungainly I think this design is. It doesn't matter if other apps use it. In my experience major companies are more likely to make interface mistakes because their marketing departments want the UI to look unique.

By comparison, look at how the phone app handles the same situation. No matter which tab you use to make a call, favorites, contacts, keypad etc, you still come back that tab's view when the call is done. If you want to make a call with another method, you just hit the appropriate tab.

Ignore the bad example of others. Why spend so much time and effort trying to reproduce someone else's mistake?

TechZen
  • 64,370
  • 15
  • 118
  • 145
  • Hi There: A and B are UITableControllers, each one is on a tab in UITabBarController. One can tab A on the tab bar to get back to A. This might be a bad design, but this is how Skype and Ebuddy do on iphone, you choose a friend from Contacts/Buddies to chat, once in Chat window, the back button leads back to Chats rather than Contacts/Buddies. This post was simplified from my another post at this link: http://stackoverflow.com/questions/2112716/iphone-instant-message-client-desgin-problem – Michael Z Jan 22 '10 at 02:18
  • Following your suggestion, If you read my last comment, since A and B are UITableViewController, how do I make sure C always go back to B? – Michael Z Jan 22 '10 at 02:21
  • Response to Edit01 Hi TechZen: Thanks very much for your reply, I think your solution would work, adopting your suggestion would drastically change my application structure.I hope this is not the only solution. This UI design is intuitive for the users, the problem lies at the implementation level. You are not quite right about how phone app handles the "same" situations. If you go to phone->choose a person->tap text message-> back button says "message" not contacts. So it is exactly the A->C->B->C->B situation Thanks so much for your input, I would keep your solution in mind for now – Michael Z Jan 23 '10 at 02:49
  • In the sequence you describe with the phone app, the phone app is actually quitting before launching the SMS app. The SMS app opens to the message detail window for the contact the phone app sent it. The back "message" button takes the user back to the view they would have seen had they opened the SMS app themselves. To get back to the phone app the user has to quit SMS and open the phone app. However, if you think your design is the best/most-familiar interface, go for it. – TechZen Jan 23 '10 at 13:21
  • That make sense. No wonder it takes a while to load the message app. Thanks TechZen – Michael Z Jan 23 '10 at 21:59
  • I asked the same question on iphone google group: Got reply as: Sukima: I believe (although I have no real idea) that what these applications like skype and Beejive are doing is when view A wants view C it will message your UITabBar to move to the chats tab then push in the detail view C. This is actually better because then the user will see that the view has changed via the fact that the tabbar has changed highlights. from: I further read the stackoverflow thread. I understand now what your asking. http://groups.google.com/group/iphone-appdev-auditors/browse_thread/thread/e602bd82eb6889fe – Michael Z Jan 24 '10 at 19:37
  • Yes, that is the best approach. – TechZen Jan 25 '10 at 12:58
0

You'll always wind up going back to the view that called pushViewController

Could you have A send B a message that causes B to call pushViewController?
I may not understand your architecture, but I believe that would work.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
justin
  • 868
  • 1
  • 5
  • 11
  • Thanks for your suggestion, might not be possible to have a send a message to B. Here is the rough design if you are intersted http://stackoverflow.com/questions/2112716/iphone-instant-message-client-desgin-problem – Michael Z Jan 22 '10 at 02:23
0

If you really want to do this you could create a method in B that pushes C then push B from A (without animation) and call the method that pushes C. Of course when you pop C to B, A will still be under it.

Jesse Anderson
  • 4,507
  • 26
  • 36
0

I got the answer from google group and followed his suggestion, it works:

From Sukima: I believe (although I have no real idea) that what these applications like skype and Beejive are doing is when view A wants view C it will message your UITabBar to move to the chats tab then push in the detail view C. This is actually better because then the user will see that the view has changed via the fact that the tabbar has changed highlights. from: I further read the stackoverflow thread. I understand now what your asking.

Michael Z
  • 4,534
  • 4
  • 21
  • 27