0

我有一个 99.9% 肖像的应用程序。然而,有一个屏幕允许横向显示,以便我们的用户在撰写帖子时可以拥有更多的空间。当用户决定在横向模式下从我们的编辑屏幕返回到只能以纵向模式显示的上一个屏幕时,我的问题就会发生,我们会切断导航栏:

时髦的导航栏

有没有人见过这个或者对如何解决这个问题有任何想法?

编辑不确定它是否明显,但发生的情况是可用于绘制 NavigationBar 的区域被截断到与视图处于横向模式时相同的高度,并且黑条是 Portrait NavigationBar 之间的差异height 和 Landscape NavigationBar 的高度。

4

2 回答 2

0

如果您正在使用:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

那么原始视图(风景)仍然存在。

使用:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

调整您的视图界面。

这都是猜测,因为您需要提供有关您正在做什么的更多信息,这就是造成这种情况的原因。

于 2012-09-04T22:10:41.190 回答
0

使用下面的代码在旋转之前转储 self.view 的超级视图和子视图,然后在旋转完成后,然后在旋转回纵向完成后再次转储。其中一个视图与其原始来源不匹配,这将是您的问题视图。原点的变化很可能是由于没有在顶部/左侧启用支柱。

这发生在我身上很多次,我写了这个 UIView 类别来转储超级和子视图。

用法:

[UIView dumpSuperviews:self.view msg:@"Original superviews"];
[UIView dumpSubviews:self.view msg:@"Original subviews"];

代码:

#import <QuartzCore/QuartzCore.h>

#import "UIView+Utilities.h"

@interface UIView (Utilities_Private)

+ (void)appendView:(UIView *)v toStr:(NSMutableString *)str;

@end

@implementation UIView (Utilities_Private)

+ (void)appendView:(UIView *)a toStr:(NSMutableString *)str
{
    [str appendFormat:@"  %@: frame=%@ bounds=%@ layerFrame=%@ tag=%d userInteraction=%d alpha=%f hidden=%d\n", 
        NSStringFromClass([a class]),
        NSStringFromCGRect(a.frame),
        NSStringFromCGRect(a.bounds),
        NSStringFromCGRect(a.layer.frame),
        a.tag, 
        a.userInteractionEnabled,
        a.alpha,
        a.isHidden
        ];
}

@end

@implementation UIView (Utilities)

+ (void)dumpSuperviews:(UIView *)v msg:(NSString *)msg
{
    NSMutableString *str = [NSMutableString stringWithCapacity:256];

    while(v) {
        [self appendView:v toStr:str];
        v = v.superview;
    }
    [str appendString:@"\n"];

    NSLog(@"%@:\n%@", msg, str);
}

+ (void)dumpSubviews:(UIView *)v msg:(NSString *)msg
{
    NSMutableString *str = [NSMutableString stringWithCapacity:256];

    if(v) [self appendView:v toStr:str];
    for(UIView *a in v.subviews) {
        [self appendView:a toStr:str];
    }
    [str appendString:@"\n"];

    NSLog(@"%@:\n%@", msg, str);
}

@end
于 2012-09-04T22:17:45.253 回答