【问题标题】:Autoresizing UINavigationBar in AnnotationView在 AnnotationView 中自动调整 UINavigationBar 的大小
【发布时间】:2012-09-20 16:22:28
【问题描述】:

在我的应用程序中,我有一个 TabbarController。其中一个选项卡会打开一个启动 iPhone 相机的视图。此 CameraView 是由另一家公司开发的 SDK 的一部分。所以我不能修改这个CameraView的类。 我的问题是我必须在这个 CameraView 中实现一个 UINavigationBar。我已经通过 annotationView 解决了这个问题(这个导航栏不是由导航控制器处理的):

[self.annotationView addSubview:navbar]; 

除了自动调整大小问题外,一切都很好。如果我将手机切换到横向模式,导航栏太短了。 我已经尝试设置 Autoresizingmask 但这没有帮助。 您有什么想法可以强制导航栏自动调整大小吗?

提前致谢

【问题讨论】:

    标签: objective-c cocoa-touch uinavigationbar


    【解决方案1】:

    尝试手动调整导航栏的框架,而不是使用自动旋转。

    -willRotateFromInterfaceOrientation:(UIInterfaceOrientation)fio toInterfaceOrientation:(UIInterfaceOrientation)tio
    {
        if(tio == UIInterfaceOrientationLandscape)
            //set navbar frame 
        else
        //...
    }
    

    【讨论】:

    • 谢谢!这是正确的方法!但我使用了'(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation'
    • shouldAutorotate.. 用于指定允许的方向。你应该使用 willAutorotate.. 来改变框架。如果正确请采纳答案,谢谢。 :)
    猜你喜欢
    • 2011-04-02
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多