全屏UI图像视图
我有一个带有导航栏和选项卡栏的应用程序。用户可以导航到以滚动视图显示图像的视图。我希望有与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过简单地设置控制器的视图,您不会将其作为子视图添加到其他任何内容,因此它永远不会出现。
像这样移动视图可能会有点棘手。我建议您不要将视图从一个视图移动到另一个视图,而是使用两个 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.
仅使用
setNavigationBarHidden:animated:
和setToolbarHidden:animated:
有什么问题吗?what's wrong with just using
setNavigationBarHidden: animated:
andsetToolbarHidden:animated:
?