我的应用程序是99.9%的肖像。然而,我们允许横向显示一个屏幕,以便我们的用户在撰写帖子时可以拥有更多的空间。我的问题发生在用户决定在横向模式下从我们的编辑屏幕返回到我们之前只能在纵向模式下显示的屏幕时,我们会将导航栏切断:
有没有人见过这个或对如何解决问题有任何想法?
编辑不确定它是否引人注目,但发生的事情是,可用于导入的NavigationBar的区域被截断到与视图处于横向模式时相同的高度,并且黑色条是Portrait NavigationBar高度和Landscape NavigationBar高度之间的差异。
答案 0 :(得分:0)
如果您正在使用:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
然后原始视图(风景)仍然存在。
使用:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
调整视图界面。
这是一个猜测,因为您需要提供有关您正在做的事情的更多信息,这就是原因。
答案 1 :(得分: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