Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么这个视图会神奇地改变大小?_Ios_Objective C_Cocoa Touch - Fatal编程技术网

Ios 为什么这个视图会神奇地改变大小?

Ios 为什么这个视图会神奇地改变大小?,ios,objective-c,cocoa-touch,Ios,Objective C,Cocoa Touch,我得到了一个tableView和一个tableFooterView 在viewDidload上: <UIView: 0x6c87a70; frame = (0 325; 320 3); autoresize = TM+BM; layer = <CALayer: 0x6c87aa0>> <UIImageView: 0x6c87b60; frame = (31 0; 257 3); autoresize = W+H; userInteractionEnabled

我得到了一个tableView和一个tableFooterView

在viewDidload上:

 <UIView: 0x6c87a70; frame = (0 325; 320 3); autoresize = TM+BM; layer = <CALayer: 0x6c87aa0>>
  <UIImageView: 0x6c87b60; frame = (31 0; 257 3); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x6c87ba0>> - table_pull_refresh_footer.png

-表\u pull\u refresh\u footer.png
在ViewWillLayoutSubview上我看到的是

<UIView: 0x6c87a70; frame = (0 325; 320 3); autoresize = TM+BM; layer = <CALayer: 0x6c87aa0>>
 <UIImageView: 0x6c87b60; frame = (31 0; 320 3); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x6c87ba0>> - table_pull_refresh_footer.png

-表\u pull\u refresh\u footer.png

那么为什么UIImageView突然变大了呢?父视图根本不会更改大小。仍然是3203。

问题正是维金戈森所说的


我应该先调用[super viewWillLayoutSubviews]

视图的边界是否更改?在记录视图之前,您的
viewWillLayoutSubviews
是否调用
[super viewWillLayoutSubviews]
?如果将普通UIViewController子类化,则不需要调用它。但对于其他视图控制器,这可能是必要的。除非你正在做一些古怪的事情,否则我无法用给出的信息重现这个问题。多一点代码会很有帮助