如何从自定义移动到半透明的NavigationBar并返回?显示问题! [英] How to move from custom to transluscent NavigationBar and back? Display problems!

查看:56
本文介绍了如何从自定义移动到半透明的NavigationBar并返回?显示问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我得到了这个基于导航的应用程序(带有自定义的NavigationBar-类别),在这里有 2 问题...

So, i got this Navigation-based App (with a custom NavigationBar - Category) and I have 2 problems here...

@implementation UINavigationBar (Custom)

- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"bg_toolbar.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

@end

由于基于导航的应用程序,大多数视图的高度 436px (=屏幕尺寸-NavigationBar的高度,您可能已经知道;).

Because of the Navigation-based App, most of the views have a height of 436px (= ScreenSize - NavigationBar height, as you probably know ;).

我得到了一个类似于照片应用程序概述的视图,其中显示了所有缩略图,从那里我推了一个包含滚动视图(如在照片应用程序中)的视图控制器,就像这样

I got one view similar to the photo app overview showing all the thumbnails, from there I push a viewcontroller containing the scroll view (like in photos app) on the stack, like so

- (void)buttonPressed:(id)sender 
{
    UIButton *btn = (UIButton *)sender;
    PhotoSetScrollViewController *psc = [[PhotoSetScrollViewController alloc] initWithPhotoArray:photos andID:btn.tag];
    [self.navigationController pushViewController:psc animated:YES]; 
}

问题1 :拥有全屏滚动视图的视图的高度 480像素,这似乎是一个问题,因为通过单击后退"按钮弹出视图控制器时,该视图包含缩略图(高度 436px )在导航栏下方向上移动.而且工具栏也不断显示.可能是什么问题?

Problem 1: The view holding the fullscreen scrollview has a height of 480px which seems to be a problem because when poping the viewcontroller by hitting the back button, the view containing the thumbnails (height 436px) moves upward below the navigation bar. And also the Toolbar keeps showing. What could be the problem?

编辑:显示导航和工具栏(最初隐藏)时,全屏滚动视图也在移动.即使没有自定义导航栏,我的视图也仍然浮动.太奇怪了.

The fullscreen scrollview is also moving when the navigation and toolbar are shown (hidden initially). And even without the custom navigationbar i get the views floating around. That is weird.

问题2 :如何在自定义导航栏和标准黑色半透明样式之间切换?

Problem 2: How could I switch between my custom navigation bar and the standard black translucent style?

推荐答案

jd,

问题1:请澄清您的问题....是否要使其与照片"应用程序相同,请在其中单击单张照片,然后隐藏导航栏和工具栏?除非您明确隐藏工具栏,否则当您通过单击后退"按钮弹出视图时,该工具栏将继续显示.您可以延迟弹出视图并将其隐藏或将其隐藏在先前视图控制器的 viewDidAppear 方法中.

Problem 1: Please clarify your question.... Are you trying to make it the same as the Photos app, where you click on a single photo and then you can hide the nav bar and the toolbar? Unless you explicitly hide the toolbar, it will continue to show when you pop your view by hitting the back button. You can delay the pop view and hide it or hide it within the viewDidAppear method of the prior view controller.

如果视图在四处移动,则可能要检查IB中的帧设置(单击相关视图后,在检查器窗口的第二个到最后一个选项卡).另外,请确保将伪造的导航栏放在XIB文件中,以便可以正确布置所有内容.

If your view is moving around, you may want to check your frame settings in IB (2nd to the last tab in the inspector window after you click on the view in question). Also, make sure you put the faked in nav bar in your XIB files so you can lay everything out correctly.

问题2:

首先,查看此帖子:使用图像或色调颜色在iPhone的uinavigationbar上?

然后也使用它:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

这篇关于如何从自定义移动到半透明的NavigationBar并返回?显示问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆