// ViewController.m
// LayoutEx
//
// Created by Thinkpad on 15/5/14.
// Copyright (c) 2015年 Exia.Guo. All rights reserved.
//
#import "ViewController.h"
#import "AutoLayout+Assist.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *rootLabel;
@property (nonatomic,strong) IBOutlet UIView *rootView;
@end
@implementation ViewController
(void)viewDidLoad {
[super viewDidLoad];
[self.rootView addSubview:self.rootLabel];
}
(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)updateViewConstraints{
[super updateViewConstraints];
UILabel* label = (UILabel*)[self.view viewWithTag:8080];
label.translatesAutoresizingMaskIntoConstraints = NO;
NSLog(@"DO UPDATE VIEW CONSTRAINTS");
NSLayoutConstraint* labelRootConstraint1 = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
NSLayoutConstraint* labelRootConstraint2 = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
[labelRootConstraint1 install:780];
[labelRootConstraint2 install:780];
}
@end
上面的代码添加成功了,xcode控制台也没有错误输出,但是在启动的时候就是没用中心对其的效果,这个是为什么呢?
这个好无语,希望大家遇到同样问题的解答一下我的疑惑,谢谢