UIViewController
z UIView
i UITableView
Ustawianie layoutMargins z UIView nie działa
UIView
|-UITableView
Próbuję marginesie konfiguracji jak poniżej:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.layoutMargins = UIEdgeInsetsMake(30, 30, 30, 30);
self.tableView.preservesSuperviewLayoutMargins = YES;
[self.view layoutIfNeeded];
}
ale nic nie dzieje się na widoku.
Oto ograniczenia z InterfaceBuilder
(lldb) po self.view.constraints
<__NSArrayM 0x786ab6e0>(
<NSLayoutConstraint:0x7896e940 UIView:0x7896e470.trailingMargin == UITableView:0x79b51a00.trailing - 16>,
<NSLayoutConstraint:0x7896e970 UITableView:0x79b51a00.leading == UIView:0x7896e470.leadingMargin - 16>,
<NSLayoutConstraint:0x7896e9a0 V:[_UILayoutGuide:0x7896e510]-(0)-[UITableView:0x79b51a00]>,
<NSLayoutConstraint:0x7896e9d0 V:[UITableView:0x79b51a00]-(0)-[_UILayoutGuide:0x7896e600]>,
<_UILayoutSupportConstraint:0x7896c7d0 V:[_UILayoutGuide:0x7896e510(0)]>,
<_UILayoutSupportConstraint:0x7896c2b0 V:|-(0)-[_UILayoutGuide:0x7896e510] (Names: '|':UIView:0x7896e470)>,
<_UILayoutSupportConstraint:0x7896cbf0 V:[_UILayoutGuide:0x7896e600(0)]>,
<_UILayoutSupportConstraint:0x7896ea00 _UILayoutGuide:0x7896e600.bottom == UIView:0x7896e470.bottom>
)
wyniku nie widać żadnych marginesów, nic się nie zmieniło w ogóle .... co mam Issinga?
iOS 8
Co zrobić, jeśli używasz 'setNeedsUpdateConstraints' przed wywołaniem' layoutIfNeeded'?Mam wrażenie, że zmiana 'layoutMargins' nie oznacza ograniczeń jako brudnych. – Andy
Zobacz [tutaj] (https://stackoverflow.com/a/34690543/5175709). Istnieje rozwiązanie inne niż iOS11. Jestem pewien, że jeśli jest to zalecane ... – Honey