[英]iphone sdk subview/superview orientation problem
i have a iphone sdk orientation issue... 我有iPhone SDK方向问题...
i push a "holding" view controller onto the navigationController. 我将一个“持有”视图控制器推到navigationController上。 The holdingViewController uses viewDidLoad to show the navigationController navbar and add a flip button to it and a selector for the flipbutton.
holdingViewController使用viewDidLoad来显示navigationController导航栏,并向其中添加一个翻页按钮和该翻页按钮的选择器。 it then adds a subview using UIViewAnimationTransitionNone showing a UIView containing a TableView.
然后使用UIViewAnimationTransitionNone添加一个子视图,该子视图显示包含TableView的UIView。 When the flip button is clicked the holding view controller removes the loaded subview and replaces with the another subview, also containing a view with a tableview, and transforms using the flip animation.
单击翻转按钮后,保持视图控制器将删除已加载的子视图,并替换为另一个子视图(也包含带有表格视图的视图),并使用翻转动画进行变换。 The problem comes when flipping and changing orientations.
当翻转和改变方向时会出现问题。 although both flipping and rotating appear to work at first if i flip while in landscape mode, the flipped view is sort of "cropped" to portrait width, although actually displayed in landscape, rotation then doesnt fix it, u have to flip back, rotate back to portrait, then flip back again.
尽管如果我在横向模式下进行翻转,虽然翻转和旋转都首先起作用,但是翻转的视图有点像“裁剪”为纵向宽度,尽管实际上以横向显示,旋转却不能解决问题,你必须向后翻转,旋转回到肖像,然后再次翻转。 It looks like the holdingview is not registering the change in orientation, but i know it is as i've implemented
好像holdingview没有在记录方向的变化,但是我知道这是我已经实现的
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
on all 3 view controllers and i can see orientationChanged function being called for each. 在所有3个视图控制器上,我可以看到针对每个视图调用了directionChanged函数。
All three viewcontrollers are setting autoresizing in viewDidLoad 所有三个viewcontroller都在viewDidLoad中设置自动调整大小
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
and i've also implemented 而且我还实施了
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
does anybody have any ideas whats going on, or more importantly, what i can do to fix it? 是否有人对发生的事情有任何想法,或更重要的是,我可以做些什么来解决它?
many thanks 非常感谢
I had a similar problem with adding a subview. 添加子视图时,我遇到了类似的问题。 The subview was being cropped while in landscape orientation.
子视图在横向放置时被裁剪。 I had to set the frame of the subview before adding it so that the subview would fill correctly.
我必须在添加子视图之前设置它的框架,以便子视图可以正确填充。
Here is the code that fixed my issue: [subcontroller.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
这是解决我的问题的代码:
[subcontroller.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.