2017-06-14 37 views
1

当激活个人热点并将其自身调整为40px时,视图无法正确调整大小。底部在屏幕下方20px而不是调整大小。个人热点中断用户界面布局

我在所有视图控制器中都使用了自动布局,但即使我的应用程序用户界面像下面显示的图像一样突破。 enter image description here

任何帮助将是伟大的。

+0

状态栏是高40个像素,而不是20时个人热点已开启。所以你应该调整约束 – AnshaD

+0

是的你的权利,但这只是一个解决方法,我需要一个具体的解决方案。谢谢你的评论。 – Nilesh

+0

请在下面检查我的答案 – AnshaD

回答

1

您可以检查我以前的答案iOS App layout is wrong with calling status bar

技术上同样的事情发生在这里被打破您的视图的自动布局。

+0

您的意思是我必须添加超级视图的约束顶部,而不是TLG,对不对? – Nilesh

+0

是的,我的项目使用这个工作很好 – Aakash

+0

我已经添加了超级视图的约束顶部,但没有解决问题。 – Nilesh

1

注册此通知在您的viewDidLoad

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(statusBarFrameWillChange:)name:UIApplicationWillChangeStatusBarFrameNotification object:nil]; 
} 



    - (void)statusBarFrameWillChange:(NSNotification*)notification 
{ 
    NSLog(@"STATUS BAR UPDATED"); 
int statusHeight = [UIApplication sharedApplication].statusBarFrame.size.height; 
NSLog(@"status bar height %d", statusHeight); 
    // Here you can do your constraint adjustments accordingly 
} 

,你可以在这里找到一个很好的教程(SWIFT)http://studyswift.blogspot.in/2015/12/adjust-ui-components-programmatically.html