splitviewcontroller的详细视图的帧大小在ios4.2中没有改变

发布于 2024-10-08 17:54:39 字数 962 浏览 0 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虐人心 2024-10-15 17:54:39

我发现解决问题的另一种方法是,不是隐藏主视图并更改旋转时详细视图的帧大小,而是将包含详细视图的类呈现为模态视图。早些时候我从上一堂课上推了它。我还添加了一个导航栏,其中带有一个完成按钮来关闭模式视图。这件事对我有用。

ListingViewController *viewController = [[ListingViewController alloc] initWithNibName:@"ListingViewController" bundle:[NSBundle mainBundle]];  
UINavigationController *modalVC = [[UINavigationController alloc]initWithRootViewController:viewController]; // to add navigation bar
modalVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController presentModalViewController:modalVC animated:YES];
[modalVC release];
[viewController release];

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.

ListingViewController *viewController = [[ListingViewController alloc] initWithNibName:@"ListingViewController" bundle:[NSBundle mainBundle]];  
UINavigationController *modalVC = [[UINavigationController alloc]initWithRootViewController:viewController]; // to add navigation bar
modalVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController presentModalViewController:modalVC animated:YES];
[modalVC release];
[viewController release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文