【问题标题】:iPhone UINavigationController problems (invisible Button, title)iPhone UINavigationController 问题(不可见的按钮、标题)
【发布时间】:2010-11-08 08:45:53
【问题描述】:

UINavigationController 有两个问题。

问题 1

在初始视图中,我以编程方式添加了一个 rightBarButtonItem。

当我将 navigationView 推到右侧时,一切正常,并出现一个带有前一个视图标题的后退按钮。

当我单击返回按钮时,我会返回。但后来这个按钮不见了。但它并没有真正消失,它只是不可见,因为它仍然可以被点击。

问题 2

当我推右边的viewController时,我无法设置标题。我在推送视图之前尝试过

myViewController.title = @"someTitle";

我也在 viewController 内部尝试过

self.title = @"someTitle";

但这里没有任何效果。

【问题讨论】:

    标签: iphone uinavigationcontroller uinavigationbar uinavigationitem


    【解决方案1】:

    我发现了问题:

    我正在向导航栏添加自定义背景图像。不知何故,这张图片超越了标题/按钮。

    因此,如果您想实现自定义背景图片,不要使用这个:

    UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
    [backgroundImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headerBg" ofType:@"png"]]];
    [navigationController.navigationBar insertSubview:backgroundImage atIndex:0];
    [backgroundImage release];
    

    但是,改用这个:

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

    【讨论】:

      【解决方案2】:

      问题 1: 听起来很奇怪。真的没有答案:-/

      问题 2: 您能否提供更多关于此的代码 sn-ps,例如您尝试设置标题的整个方法体?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-15
        • 1970-01-01
        • 1970-01-01
        • 2023-03-09
        • 2011-01-15
        • 1970-01-01
        • 1970-01-01
        • 2012-05-31
        相关资源
        最近更新 更多