1. Explanation
In uiview, there is an autoresizingmask attribute, which corresponds to an enumerated value (as follows). The attribute means to automatically adjust the position between the child control and the parent control, with a width and height.
| 123456789 |
enum { UIViewAutoresizingNone = 0, UIViewAutoresizingFlexibleLeftMargin = 1 << 0, UIViewAutoresizingFlexibleWidth = 1 << 1, UIViewAutoresizingFlexibleRightMargin = 1 << 2, UIViewAutoresizingFlexibleTopMargin = 1 << 3, UIViewAutoresizingFlexibleHeight = 1 << 4, UIViewAutoresizingFlexibleBottomMargin = 1 << 5}; |
Uiviewautoresizingnone is not automatically adjusted.
Uiviewautoresizingflexibleleftmargin automatically adjusts the distance from the left side of superview to ensure that the distance from the right side of superview remains unchanged.
Uiviewautoresizingflexiblerightmargin automatically adjusts the right distance from the superview to ensure that the left distance from the superview remains unchanged.
Uiviewautoresizingflexibletopmargin automatically adjusts the distance from the superview top to ensure that the distance from the superview bottom remains unchanged.
Uiviewautoresizingflexiblebottommargin automatically adjusts the distance from the superview bottom, that is, the distance from the superview top remains unchanged.
Uiviewautoresizingflexiblewidth automatically adjusts its width to ensure the distance from the left and right sides of superview.
Uiviewautoresizingflexibleheight automatically adjusts its height to ensure the distance from the top and bottom of the superview.
Uiviewautoresizingflexibleleftmargin. For example, if the original distance is 20, 30, the adjusted distance should be 68,102, that is, 68/20 = 102/30.
Other combinations are similar.
2. Instance
Create a tableview as follows:
_videoTable = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain]; _videoTable.backgroundColor = [UIColor yellowColor]; _videoTable.dataSource = self; _videoTable.delegate = self; _videoTable.autoresizingMask = UIViewAutoresizingFlexibleHeight;//1 [self.view addSubview:_videoTable];
Compare the effect of comments and comments on code 1:
The gray part at the bottom is a view. The left-side figure shows the effect of setting the autoresizingmask attribute of the table, and no effect is set on the right.
3. Reference
Http://blog.csdn.net/yuquan0821/article/details/7596545