全屏UI图像视图

发布于 2024-09-18 01:58:13 字数 583 浏览 9 评论 0原文

我有一个带有导航栏和选项卡栏的应用程序。用户可以导航到以滚动视图显示图像的视图。我希望有与 iPhone 照片应用程序相同的行为:导航栏位于顶部,工具栏位于底部,它将根据点击隐藏或显示。

我将视图移动到窗口对象以实现全屏模式。这工作正常:

    myView = [self.view retain];
    self.view = nil;
    [window addSubview:myView];

但是当我想重新显示导航和工具栏,我遇到了问题。条形显示正常,但视图是空的,我似乎无法向视图添加任何内容:

    [myView removeFromSuperview];
    self.view = myView;

我从 这篇文章

但无法完全获得正确的组合。

I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.

I'm moving my view to the window object in order to achieve full screen mode. This works fine:

    myView = [self.view retain];
    self.view = nil;
    [window addSubview:myView];

But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:

    [myView removeFromSuperview];
    self.view = myView;

I got a lot of good info from this post

but can't quite get the right combination.

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

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

发布评论

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

评论(2

紫轩蝶泪 2024-09-25 01:58:13

通过简单地设置控制器的视图,您不会将其作为子视图添加到其他任何内容,因此它永远不会出现。

像这样移动视图可能会有点棘手。我建议您不要将视图从一个视图移动到另一个视图,而是使用两个 UIView。将第二个 UIView 添加到窗口的子视图并将其初始设置为 hide=YES。当你想显示它时,为UIImageView设置图像,然后将隐藏属性设置为NO。

By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.

Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.

失去的东西太少 2024-09-25 01:58:13

仅使用 setNavigationBarHidden:animated:setToolbarHidden:animated: 有什么问题吗?

what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?

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