back button goes back to a different UITableViewController from where it came from

北慕城南 提交于 2019-12-11 04:13:46

问题


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.


回答1:


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?




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/2113387/back-button-goes-back-to-a-different-uitableviewcontroller-from-where-it-came-fr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!