iphone sdk子视图/超级视图方向问题
我有一个 iphone sdk 方向问题...
我将一个“保持”视图控制器推到导航控制器上。 HoldingViewController 使用 viewDidLoad 来显示 navigationController 导航栏,并向其添加一个翻转按钮和一个翻转按钮选择器。然后,它使用 UIViewAnimationTransitionNone 添加一个子视图,显示包含 TableView 的 UIView。单击翻转按钮时,持有视图控制器将删除加载的子视图并替换为另一个子视图,该子视图也包含带有表视图的视图,并使用翻转动画进行转换。当翻转和改变方向时就会出现问题。虽然如果我在横向模式下翻转,翻转和旋转似乎首先都可以工作,但翻转的视图有点“裁剪”为纵向宽度,尽管实际上以横向显示,但旋转并不能修复它,你必须向后翻转,旋转返回纵向,然后再次翻转回来。看起来 HoldingView 没有注册方向的变化,但我知道这是因为我已经
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
在所有 3 个视图控制器上实现了,并且我可以看到每个视图控制器都调用了orientationChanged 函数。
所有三个视图控制器都在 viewDidLoad 中设置自动调整大小
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
,我也实现了
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
有人知道发生了什么,或者更重要的是,我可以做些什么来解决它?
非常感谢
i have a iphone sdk orientation issue...
i push a "holding" view controller onto the navigationController. The holdingViewController uses viewDidLoad to show the navigationController navbar and add a flip button to it and a selector for the flipbutton. it then adds a subview using UIViewAnimationTransitionNone showing a UIView containing a TableView. 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
[[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.
All three viewcontrollers are setting autoresizing in 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在添加子视图时遇到了类似的问题。子视图在横向时被裁剪。我必须在添加子视图之前设置子视图的框架,以便子视图能够正确填充。
这是解决我的问题的代码:
[subcontroller.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
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)];