1

This is typical question and possibly duplicated, but..

There is iPad app which has UINavigationBar and UITabBar. I have created a button on navigationBar which must show appinfoViewController.

When I present it navigationBar and tabTab are still available to tap. But I would like to show appinfoViewController to full app's main screen size (like modal)

This is my code:

- (void)showInfo
{
AboutViewController *about = [[AboutViewController alloc] init];
[about.view setFrame: self.view.frame];
[about.view setAlpha:0.0];

[UIView animateWithDuration:0.5
                      delay:0.0
                    options: UIViewAnimationOptionCurveLinear
                 animations:^{
                     [about.view setAlpha:1.0];

                     [self.view addSubview:about.view];
                     [self addChildViewController:about];
                     [about didMoveToParentViewController:self];
                 }
                 completion:^(BOOL finished){

                 }];
}

How to present appinfoViewController to full screen?

May be it's possible to present it modally but without BLACK background?

4

3 回答 3

1

正如评论中所建议的,使用

[self presentViewController:about animated:YES completion:nil]

将摆脱导航栏和标签栏。如果需要保留它们,则需要使用

[self.navigationController pushViewController:about animated:YES];

编辑:

为了让除了关于视图之外的所有地方都禁用用户交互,这有点棘手:首先,您需要将所有 UI 元素嵌入到一个不是呈现视图控制器的主视图的视图中。

假设您只有一个按钮(“显示”按钮),您不会只是将它放在主视图中,而是会使用另一个视图(我们称之为“外部视图”),它与查看控制器的视图以及放置按钮的位置(以及您可能拥有的任何其他 ui 元素)。你还需要这个外部视图的出口。然后写一个方法如:

-(void)userInteractionEnabled:(BOOL)enabled
{   
    self.navigationController.navigationBar.userInteractionEnabled = enabled;
    self.tabBarController.tabBar.userInteractionEnabled = enabled;
    self.outerView.userInteractionEnabled = enabled;
}

或者,您可以简单地禁用每个“交互式”插座而不是 outerView。因此,例如,如果您有 2 个文本视图、3 个按钮和一个 UIPickerView,您将为userInteractionEnabled = enabled这些插座中的每一个进行设置(而不是只为父视图执行此操作)。

现在,在您的 showInfo 方法中,您可以拥有:

 CGRect frame = CGRectMake(50, 50, 200, 200); //Use whatever origin and size you need
 about.view.frame = frame;
 [self.view addSubview:about.view];
 [self userInteractionEnabled:NO]

在您的 btnClose 方法中,您可以输入:

[about.view removeFromSuperview];
[self userInteractionEnabled:YES];

我希望这会有所帮助,让我知道这是否是您需要的!

PS 也许你已经意识到这一点,但是有一个类UIPopoverController,仅适用于 iPad 的应用程序,它几乎可以为你完成所有这些。您可以在此处找到有关如何使用它的教程。

于 2013-06-14T09:17:46.617 回答
0
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];

    AboutViewController *about = (AboutViewController *)[storyBoard instantiateViewControllerWithIdentifier:@"about"];

[self.navigationController pushViewController:关于动画:YES];

于 2013-06-17T07:07:33.737 回答
0

您可以直接添加 viewcontroller 视图层来呈现 viewcontroller 视图。

代码应该是这样的——

AboutViewController *about = [[AboutViewController alloc] init];
[about.view setFrame: self.view.bound];
[about.view setAlpha:0.0];
[self.view addSubview:about.view];

[UIView animateWithDuration:0.5
                      delay:0.0
                    options: UIViewAnimationOptionCurveLinear
                 animations:^{
                     [about.view setAlpha:1.0];
                 }
                 completion:^(BOOL finished){

                 }];
于 2013-06-18T09:48:50.007 回答