如何使用标签栏以全屏模式打开 UIView?

发布于 2024-10-08 22:40:34 字数 917 浏览 10 评论 0原文


这是我的问题。

  1. 我有一个 tabBar 应用程序。
  2. 在第一个选项卡中,我有一个表格。
  3. 单击表格时,它会显示一个模式 view.
  4. 从模态视图返回到第一个 视图 查看,我用
[selfpresentModalViewController:nwanimated:YES];

问题是,如果我在打开模式视图时单击选项卡栏,它将打开第二个视图,但第一个视图的表格不起作用,因为模式视图仍然打开,尽管它显示为关闭。

这是一种在全屏模式下打开模式视图并覆盖选项卡栏的方法吗?
或者还可以从另一个视图检查模态视图是否关闭?


编辑: 我尝试了所有这些代码:

 nw = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
 nw.modalInPopover = YES;
 nw.wantsFullScreenLayout = YES;
 nw.hidesBottomBarWhenPushed = YES;
 nw.contentSizeForViewInPopover = CGSizeMake(320, 480);
 nw.modalPresentationStyle = UIModalPresentationFullScreen;
 nw.view.frame = [[UIScreen mainScreen] applicationFrame];
 [nw.view setNeedsLayout];

但什么也没有!!!它不会进入全屏!

有什么想法吗?

谢谢,
阿尔贝托

this is my problem.

  1. I have a tabBar application.
  2. In first tab, i have a table.
  3. On click on table it shows a modal
    view.
  4. To go back from modal view to first
    view, i use
[self presentModalViewController:nw animated:YES];

The problem is that if i click on the tabbar while is opened a modal view, it opens second view, but first view's table don't work because the modal view is still opened althoug it appear as closed.

It's a way to open modal view in fullscreen covering the tab bar?
Or also to check if modal view is closed or not from another view?

EDIT:
I tried with all of this code:

 nw = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
 nw.modalInPopover = YES;
 nw.wantsFullScreenLayout = YES;
 nw.hidesBottomBarWhenPushed = YES;
 nw.contentSizeForViewInPopover = CGSizeMake(320, 480);
 nw.modalPresentationStyle = UIModalPresentationFullScreen;
 nw.view.frame = [[UIScreen mainScreen] applicationFrame];
 [nw.view setNeedsLayout];

but nothing!!! It wan't go in fullscreen!!

Any idea please?

thanks,
alberto

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

话少心凉 2024-10-15 22:40:34

如果您呈现的视图是全屏,这应该会遮挡选项卡栏。也就是说,您可能需要以编程方式重新调整视图的大小,使其与 UIWindow 的大小相同。

您应该能够按照以下方式做一些事情

[nw setFrame:[[UIScreen mainScreen] applicationFrame]];
[nw setNeedsLayout];

来实现这一目标。 (抱歉,我现在使用的是 Windows 盒子,所以我无法确认这一点。希望有人能在需要时提供任何调整。)

然后,您应该通过原始类中的委托方法关闭初始模式视图。 (请参阅 Apple 的 View 的“关闭模态视图控制器”部分iOS 控制器编程指南。)然后,原始类将处理模式视图。

If the view you're presenting is full screen, this should obscure the tab bar. That said, you might need to re-size the view programmatically so that it's the same size as the UIWindow.

You should be able to do something along the lines of...

[nw setFrame:[[UIScreen mainScreen] applicationFrame]];
[nw setNeedsLayout];

...to achieve this. (Sorry, I'm on a Windows box at the moment, so I can't confirm this. Hopefully someone will provide any tweaks if required.)

You should then dismiss the initial modal view via a delegate method in the originating class. (See the "Dismissing a Modal View Controller" section of Apple's View Controller Programming Guide for iOS.) The originating class would then dispose of the modal view.

罗罗贝儿 2024-10-15 22:40:34

使用通知解决!

当选项卡更改时,我发送通知并关闭模式控制器。

- (BOOL)tabBarController:(UITabBarController *)tbController shouldSelectViewController:(UIViewController *)viewController { 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DataComplete" object:nil];
    return YES;
}

在我看来,类收到通知并关闭控制器!

- (void)downloadDataComplete:(NSNotification *)notif {
    NSLog(@"Received Notification");

    [self dismissModalViewControllerAnimated:YES];
}

现在可以重新打开模态视图并更改选项卡!
这是一个解决方法,但有效!

阿尔贝托.

Resolved using notification!

When a tab change, i send a notification and close the modal controller.

- (BOOL)tabBarController:(UITabBarController *)tbController shouldSelectViewController:(UIViewController *)viewController { 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DataComplete" object:nil];
    return YES;
}

In my view classes receive a notification and dismiss the controller!

- (void)downloadDataComplete:(NSNotification *)notif {
    NSLog(@"Received Notification");

    [self dismissModalViewControllerAnimated:YES];
}

Now it's possibile to reopen a modal view also changing tab!
This is a workaround but works!

alberto.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文