在 iPad 中使用 PresentModalViewController 时出现问题
在我当前的 iPad 应用程序中,我有一个分屏视图,其中详细视图是一个包含 4 个表格视图的滚动视图。我试图实现的功能是,当我单击滚动视图中表格的任何行时,会显示一个包含附加信息的屏幕,我使用presentModalViewController 来尝试获取此功能。
举例来说,我有 3 个文件 aViewController、bViewController、cViewController.. 我正在项目的 appDelegate 文件中编写 splitViewController 的代码,并将 3 个视图控制器(aViewController、bViewController、cViewController)保留为 splitViewController ...
现在在我的一个ViewController中,比如说aViewController,在它的didSelectRowAtIndexPath中,我添加如下代码
这就是我所做的,
PopOverControllerContents *popContents =
[[PopOverControllerContents alloc]
initWithNibName:@"PopOverControllerContents"
bundle:[NSBundle mainBundle]];
popContents.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:popContents animated:YES
我想要做的一件重要的事情值得一提的是,我的应用程序的默认方向是横向模式,因此我将 PopOverControllerContents 的方向更改为横向。
当我构建并运行时,当我单击 aViewController 中的任何行时,确实会出现一个弹出视图,但它完全不在位置,并且其底部被切断。
有人能告诉我我做错了什么以及我该如何纠正吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[UIViewController PresentModalViewController::]
假设您的视图控制器是根控制器或者位于控制器层次结构中的某个位置。当你说你的控制器视图是 SplitViewController 的子视图时,它们也是它的子控制器吗?您应该尝试从SplitViewController
呈现模态控制器,或者检查您的控制器是否是它的子控制器(iOS 5 中的新功能)。[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 aSplitViewController
are they also its child controllers? You should try to present the modal controller from theSplitViewController
or check that you controllers are it's child controllers (new feature in iOS 5).