【发布时间】:2013-12-09 02:02:58
【问题描述】:
我在导航控制器视图的超级视图中添加了一个topLayoutGuide约束,然后当我尝试更改导航控制器视图的框架时,例如:从(0,0,320,568)的当前框架到(200, 0, 320, 568) 使用
[[navigationController view] setFrame:CGRectMake(200, 0, 320, 568)];
动画结束后自动设置为 (0, 0, 320, 568)。
topLayoutGuide 约束是由这段代码添加的:
- (void)viewDidLoad { // of subclassed UINavigationController class .m file
[super viewDidLoad];
// Do any additional setup after loading the view.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) {
[[self view] setTranslatesAutoresizingMaskIntoConstraints:NO];
id topGuide = [self topLayoutGuide];
UIView * selfView = [self view];
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (selfView, topGuide);
[[[self view] superview] addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topGuide]-0-[selfView]"
options:0
metrics:nil
views:viewsDictionary]];
[[[self view] superview] layoutSubviews]; // Must call this method here or the system raises an exception
}
}
【问题讨论】:
标签: ios autolayout