iPad Full Screen Modal View over TabBarController?

。_饼干妹妹 提交于 2020-01-13 18:08:14

问题


On a TabBar-based application on the iPad, is there a way to present a modal on top of it in "FullScreen"?

I have a LANDSCAPE ONLY APP (if that makes a difference) and the item I want to currently present modally I would like to present full screen, filling the entire screen just to clarify. I can present it in "PageSheet" fine, and "FormSheet" is all right, after a few button adjustments on the modal view nib, but once I try "FullScreen", the background goes white (TabBar still there, though), and if I retry hitting the button (without restarting the simulator), it won't respond.

The view where the button is located to present the modal view is CountryViewController.m and has the action:

-(IBAction) showNewModal:(id)sender {
modalContent.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
modalContent.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:modalContent animated:YES];
}

This code works fine without the TabBar, I've realized. I've looked for hours for something to add to this code or even in the AppDelegate.h and .m files but so far, it's either unresponsive (oddly enough without showing an error) or the aforementioned white space.


回答1:


in my experience the problem comes from presenting the modal from the wrong controller.

[self.tabBarController presentModalViewController:modalContent animated:YES];

should work

If you work with iOS 4 a (maybe) beter options is to use:

[[UIApplication sharedApplication].keyWindow.rootViewController presentModalViewController:modalContent animated:YES];


来源:https://stackoverflow.com/questions/5892538/ipad-full-screen-modal-view-over-tabbarcontroller

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