UIToolbar items don't move when frame is updated

Synopsis: My toolbar items are not moving with the UIToolbar when the frame is changed.

Details: I have a UIToolbar that I programmatically set up at the bottom of the screen in portrait mode.

CGRect frame = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 50, [[UIScreen mainScreen] bounds].size.width, 50);
toolbar = [[UIToolbar alloc]initWithFrame: frame];
//.... create a NSArray of toolbar items called toolbarItems 
[self.view addSubview:toolbar];
[toolbar setItems:toolbarItems];

When the screen is rotated to landscape mode I change the frame so that it sits on one side (in this case, the left side):

toolbar.frame = CGRectMake(0, 0, 50, [[UIScreen mainScreen] bounds].size.height);

The toolbar frame moves just fine, but the button items are still displayed at the bottom of the screen where they were in portrait mode.

Is there a way to tell the toolbar to update its contents? I have also tried removing and recreating the toolbar and adding new items, but this still happens.

链接地址: http://www.djcxy.com/p/58390.html

上一篇: 有什么方法可以检测iOS 6上的漫游状态吗?

下一篇: 更新帧时,UIToolbar项不会移动