我在 UIScrollView 中有一系列 UIView,当根视图控制器接收到 willAnimateRotationToInterfaceOrientation:duration 时,我试图调整它们的大小:
这是代码...
(面板只是一个扩展的 UIView;面板是一个 NSMutableArray 的面板,由扩展的 UIScrollView 持有)
for(Panel * panel in panels)
{
panel.bounds = CGRectMake(panel.bounds.origin.x,
panel.bounds.origin.y,
self.bounds.size.width,
panel.bounds.size.height);
}
NSLog(@"%@", [panels description]);
这self.bounds.size.width
是 UIScrollView (我已经扩展了类)。
这是设备面向横向时 NSLog 的结果...
"<Panel: 0x74324d0; frame = (-80 0; 480 50); animations = { bounds=<CABasicAnimation: 0xe1339d0>; }; layer = <CALayer: 0x7432530>>",
"<Panel: 0x7435ce0; frame = (-80 53; 480 50); animations = { bounds=<CABasicAnimation: 0xe133a90>; }; layer = <CALayer: 0x7435d40>>",
"<Panel: 0x7438e20; frame = (-80 106; 480 50); animations = { bounds=<CABasicAnimation: 0xe133ab0>; }; layer = <CALayer: 0x7438e80>>",
"<Panel: 0x7438eb0; frame = (-80 159; 480 50); animations = { bounds=<CABasicAnimation: 0x714f890>; }; layer = <CALayer: 0x7438f10>>",
"<Panel: 0x7438f40; frame = (-80 212; 480 50); animations = { bounds=<CABasicAnimation: 0x742ffd0>; }; layer = <CALayer: 0x7438fa0>>"
当它变回肖像时......
"<Panel: 0x7480350; frame = (0 0; 320 50); animations = { bounds=<CABasicAnimation: 0x74a3b40>; }; layer = <CALayer: 0x74803b0>>",
"<Panel: 0x7483c90; frame = (0 53; 320 50); animations = { bounds=<CABasicAnimation: 0x74a3bd0>; }; layer = <CALayer: 0x7483cf0>>",
"<Panel: 0x7486dd0; frame = (0 106; 320 50); animations = { bounds=<CABasicAnimation: 0x74a3c60>; }; layer = <CALayer: 0x7486e30>>",
"<Panel: 0x7486e60; frame = (0 159; 320 50); animations = { bounds=<CABasicAnimation: 0x74a3cf0>; }; layer = <CALayer: 0x7486ec0>>",
"<Panel: 0x7486ef0; frame = (0 212; 320 50); animations = { bounds=<CABasicAnimation: 0x74a3d80>; }; layer = <CALayer: 0x7486f50>>"
我看不出为什么 bounds.origin.x 应该是它从 (0) 开始的任何东西。这一定很明显,但我就是看不到——也许一些新的眼睛会看到我做错了什么。