Presenting a new View Controller Keeping Tab Bar

*爱你&永不变心* 提交于 2019-12-13 14:52:14

问题


I'm currently developing an iPhone App supporting iOS6+. The structure of the application has a UITabBarController as the root controller with a number of view controllers assigned to that. On one of the tabs is a UITableViewController with a list of items that, when selected, displays a detail view of that item using a push seque.

However, I also have another screen that allows QR scanning. When the QR code is scanned, the result is processed to retrieve an id that I then want to display the detail view page for the matching item (as above).

I can get this to display using the following code in the QR scanning view controller, but this loses the tab bar and any hope of navigation at this point.

[self presentViewController:detailController animated:YES completion:nil];

Is there any way that I can present the detail view controller, but still keep the tab bar (and ideally the navigation bar) that I'd get when going through the UITableView route? Everything that I've found so far references presentModalViewController but that seems to have been deprecated as of iOS6 and replaced with presentViewController.

Thanks in advance for any help or suggestions,

PhilHalf


回答1:


The modal view will come over all view replacing eventually a tabBarController, NavigationCOntroller etc...

Modal view :
Can works for all view controllers
Is over all other view and need to be pop programatically (adding a button back manually for example)

Push View :
Only works in navigation controllers
Add automatically a back button in the navigationController

I believe that what you want is a pushView which will be integrate in your navigationController :

[self.navigationController pushViewController:viewController animated:YES];



回答2:


Use this

[self.navigationController pushViewController:detailController animated:YES completion:nil];

it will show the details view with the tab bar in the bottom along with the navigation bar in the top if you dont want the navigation bar in the top just hide it with hide property.



来源:https://stackoverflow.com/questions/20264010/presenting-a-new-view-controller-keeping-tab-bar

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