0
我遇到一個奇怪的調整行爲。UIView調整子視圖的大小
當我調整一個UIView,它的子視圖的高度變爲0
我會想象下面的代碼將只調整的觀點 - 而不是它的子視圖。
NSLog(@"view = %@", view);
NSLog(@"subview = %@", subview);
CGRect frame = view.frame;
frame.size.height = 50;
view.frame = frame;
NSLog(@"view = %@", view);
NSLog(@"subview = %@", subview);
然而,上述得到以下輸出:
view = <UIView: 0x97e68c0; frame = (0 0; 320 400); autoresize = RM+BM; layer = <CALayer: 0x97e5f10>>
subview = <UIView: 0xb87f510; frame = (0 0; 320 50); autoresize = W+H; layer = <CALayer: 0xb87f020>>
view = <UIView: 0x97e68c0; frame = (0 0; 320 50); autoresize = RM+BM; layer = <CALayer: 0x97e5f10>>
subview = <UIView: 0xb87f510; frame = (0 0; 320 0); autoresize = W+H; layer = <CALayer: 0xb87f020>>
任何想法?
修復它。謝謝!我從面具中刪除了UIViewAutoresizingFlexibleHeight(通過界面生成器),它像一個魅力一樣工作。謝謝! – bbrame