// 布局子视图:当屏幕旋转的时候,可以重新布局子视图的位置
- (void)layoutSubviews {
// 如果是竖屏,保持原来的尺寸
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
self.button.frame = CGRectMake(50, CGRectGetMaxY(self.userTextField.frame) + 20, CGRectGetWidth(self.frame) - 100, 50);
} else { // 否则横屏改变位置
self.button.frame = CGRectMake(50, CGRectGetMaxY(self.userLabel.frame) + 20, 636, 50);
}