Problem using presentModalViewController in Ipad

雨燕双飞 提交于 2019-12-10 19:22:33

问题


In my current Ipad app, I have a split screen view in which the detail view is a scroll view containing 4 table views. The functionality I was trying to achive was that when I click any row of the table in the scroll view, a screen is show containing additional information and I used presentModalViewController to try to get this functionality.

say for example, I have 3 files aViewController, bViewController, cViewController.. I am writing the code for splitViewController in the appDelegate file of my project and I keep the 3 view Controllers (aViewController, bViewController, cViewController) as subviews of the splitViewController...

Now in one of my ViewControllers, say aViewController, in its didSelectRowAtIndexPath, I add the code as follows

This is what I did,

PopOverControllerContents *popContents = 
        [[PopOverControllerContents alloc] 
         initWithNibName:@"PopOverControllerContents" 
         bundle:[NSBundle mainBundle]];
 popContents.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:popContents animated:YES

An important thing I want to mention is that, my app's default orientation is landscape mode and hence I changed the orientation of PopOverControllerContents to landscape orientation.

When I build and run and when I click any row in aViewController, a popup view does come but its totally out of position and its bottom part gets cut off.

Would anyone be able to tell me what I am doing wrong and How I can correct it?


回答1:


[UIViewController presentModalViewController::] supposes that your view controller is the root controller or it is somewhere in the controller hierarchy. When you say that your controller views are subview of a SplitViewController are they also its child controllers? You should try to present the modal controller from the SplitViewController or check that you controllers are it's child controllers (new feature in iOS 5).



来源:https://stackoverflow.com/questions/5624457/problem-using-presentmodalviewcontroller-in-ipad

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