I create a view which inherits UIView
and add it to a superView
. But when I check the view's frame, I found it has been changed. But my code doesn't do it. I don't know why. Let's see the Code.
- (void)addBottomView
{
NSArray *viewArray = [[NSBundle mainBundle] loadNibNamed:@"WYOrderDetailBottomView" owner:nil options:nil];
if (viewArray.count > 0) {
self.bottomContentView = viewArray.firstObject;
}
self.bottomContentView.delegate = self;
self.bottomContentView.frame = CGRectMake(0.0f, 0.0f, SCREENWIDTH, 0.0f);
MLOG(@"%@", NSStringFromCGRect(self.bottomContentView.frame));
self.bottomViewHeightConstraint.constant = 0.0f;
[self updateViewConstraints];
[self.view layoutIfNeeded];
MLOG(@"%@", NSStringFromCGRect(self.bottomContentView.frame));
[self.bottomBackView addSubview:self.bottomContentView];
MLOG(@"%@", NSStringFromCGRect(self.bottomContentView.frame));
}
this method is invoked in viewDidLoad
like this, the log of view's frame is (0,0,375,0) in iphone6.
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"预约单详情";
self.isNeedRefreshUI = YES;
[self addBottomView];
[self configTableView];
[self addNotificationObserver];
}
But in another method, I check the frame of the view(self.bottomContentView).
- (void)getOrderDetailInfo
{
MLOG(@"%@", NSStringFromCGRect(self.bottomContentView.frame));
}
the frame changed to (0, 0, 430, 0), I don't write any code to change it's frame. How it works?