iPhone 视图显示方向错误
我正在努力解决这个问题。 我的应用程序需要一个纵向视图和一个横向视图。现在,当我创建两个显示纵向视图和横向视图的按钮(由 shouldAutorotateToInterfaceOrientation 强制)时,它们显示得很好。但是,当我从图像选择器的结果代码中调用视图时,纵向视图工作得很好,但横向视图像这样返回。 http://bit.ly/bfbobc。
所以只要说清楚:旋钮已经旋转了 90 度,imageviewcontrol 仅显示一半(右侧部分在屏幕外)...但是 iPhone 并没有强制进入横向模式...
有人可以解释一下吗我这里发生了什么或者我如何实现这一目标!欢迎任何帮助!
这就是我如何使用 imagepickercontroller 结果代码调用视图。
`- (void) imagePickerController:(UIImagePickerController *)vcImagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSLog(@"图片已拍摄/选择,现在我们需要决定呈现哪个视图");
[vcImagePicker dismissModalViewControllerAnimated:YES];
UIImage *chosenPicture = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
if (chosenPicture.size.width > chosenPicture.size.height) {
NSLog(@"pic is in landscape");
EditLandscapeScreen *vcEditLandscapeScreen = [[EditLandscapeScreen alloc] initWithNibName:@"EditLandscapeScreen" bundle:nil];
vcEditLandscapeScreen.ChosenImage = chosenPicture;
[self.view addSubview:vcEditLandscapeScreen.view];
[vcEditLandscapeScreen release];
}
else {
NSLog(@"pic is in portrait");
EditPortraitScreen *vcEditPortraitScreen = [[EditPortraitScreen alloc] initWithNibName:@"EditPortraitScreen" bundle:nil];
vcEditPortraitScreen.ChosenImage = chosenPicture;
[self.view addSubview:vcEditPortraitScreen.view];
[vcEditPortraitScreen release];
}
}`
I'm wrestling with this problem.
I need a portrait view and a landscape view for my App. Now when I create 2 buttons that show me a portrait view and a landscape view (forced by shouldAutorotateToInterfaceOrientation) they show up just fine. But when I call the views from within the result code of an imagepicker, the portraitview works just fine, but the landscape view get returned like this. http://bit.ly/bfbobc.
So just the make it clear: the nob is already turned 90 degrees, the imageviewcontrol is only shown half (the right part is off-screen)... But the iPhone isn't forced into landscape mode...
Can someone please explain me what's going on here or how I can achieve this! Any help is welcome!
This is how I call the views from withing the imagepickercontroller result code.
`- (void) imagePickerController:(UIImagePickerController *)vcImagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSLog(@"The picture was taken/chosen, now we need to decide which view to present");
[vcImagePicker dismissModalViewControllerAnimated:YES];
UIImage *chosenPicture = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
if (chosenPicture.size.width > chosenPicture.size.height) {
NSLog(@"pic is in landscape");
EditLandscapeScreen *vcEditLandscapeScreen = [[EditLandscapeScreen alloc] initWithNibName:@"EditLandscapeScreen" bundle:nil];
vcEditLandscapeScreen.ChosenImage = chosenPicture;
[self.view addSubview:vcEditLandscapeScreen.view];
[vcEditLandscapeScreen release];
}
else {
NSLog(@"pic is in portrait");
EditPortraitScreen *vcEditPortraitScreen = [[EditPortraitScreen alloc] initWithNibName:@"EditPortraitScreen" bundle:nil];
vcEditPortraitScreen.ChosenImage = chosenPicture;
[self.view addSubview:vcEditPortraitScreen.view];
[vcEditPortraitScreen release];
}
}`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将子视图添加到视图,则必须自己更改子视图的方向。
willRotateToInterfaceOrientation
只会为第一个视图控制器调用,因此如果您将子视图添加到视图控制器,这可能是您可以接受的方式:在您的 ViewController 中:
在您的子视图 ViewController 中:
这可能您会朝正确的方向前进。
If you add a Subview to a View you have to make the Orientation changes for your Subview yourself.
willRotateToInterfaceOrientation
only will get called for the first viewcontroller so if you add Subviews to a viewcontroller this may be a acceptable way for you:in your ViewController:
in you Subview ViewController:
This may you get in the right direction.