我在UIScrollView中有一系列UIViews,我试图在根视图控制器收到willAnimateRotationToInterfaceOrientation时调整大小:duration:
这是代码......
(Panel只是一个扩展的UIView;面板是由扩展的UIScrollView持有的面板的NSMutableArray)
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)开始的东西之外的任何原因。它一定是明显的东西,但我只是看不到它 - 也许一些新鲜的眼睛会看到我做错了什么。
答案 0 :(得分:0)