splitviewcontroller的详细视图的帧大小在ios4.2中没有改变
我正在 ipad 应用程序中使用两个视图主视图和详细视图来实现 splitviewcontroller。在将 ipad 的方向从纵向更改为横向时,我需要隐藏主视图并更改详细视图的框架大小以在全屏上显示。为此,我正在使用这段代码。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
//adjust master view
UIViewController *master = [self.splitViewController.viewControllers objectAtIndex:0];
UIViewController *detail = [self.splitViewController.viewControllers objectAtIndex:1];
CGRect t = master.view.frame;
t.size.width = 0;
t.size.height = 0;
t.origin.x = 0;
t.origin.y = 0;
[master.view setHidden:YES];
[master.view setFrame:t];
//adjust detail view
CGRect f = detail.view.frame;
f.size.width = 1004;
f.size.height = 768;
f.origin.x = 0;
f.origin.y = 0;
[detail.view setFrame:f];
}
此代码在 ios3.2 上运行完全正常,但不适用于 ios4.2。主视图在 ios4.2 中被隐藏,但详细视图的框架大小不会改变。
请帮我。 谢谢 什鲁蒂
I am implementing splitviewcontroller with two views master view and detail view in my ipad application. On changing the orientation of ipad from portrait to landscape I am need to hide the master view and change the detail view's frame size to show up on full screen. For this I am using this code.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
//adjust master view
UIViewController *master = [self.splitViewController.viewControllers objectAtIndex:0];
UIViewController *detail = [self.splitViewController.viewControllers objectAtIndex:1];
CGRect t = master.view.frame;
t.size.width = 0;
t.size.height = 0;
t.origin.x = 0;
t.origin.y = 0;
[master.view setHidden:YES];
[master.view setFrame:t];
//adjust detail view
CGRect f = detail.view.frame;
f.size.width = 1004;
f.size.height = 768;
f.origin.x = 0;
f.origin.y = 0;
[detail.view setFrame:f];
}
This code works exactly fine on ios3.2 but does not work for ios4.2. The master view gets hidden in ios4.2 but detail view's frame size does not change.
Please help me.
Thanks
Shruti
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现解决问题的另一种方法是,不是隐藏主视图并更改旋转时详细视图的帧大小,而是将包含详细视图的类呈现为模态视图。早些时候我从上一堂课上推了它。我还添加了一个导航栏,其中带有一个完成按钮来关闭模式视图。这件事对我有用。
The alternative that I found to my problem is that instead of hiding the master view and changing the frame size of detail view on rotation I just presented the class containing the detail view as the modal view. Earlier I was pushing it from the previous class. I also added a navigation bar to it with a done button to dismiss the modal view. This thing worked for me.