我正在努力解决这个问题 . 我的App需要纵向视图和横向视图 . 现在,当我创建2个按钮,向我显示纵向视图和横向视图(由shouldAutorotateToInterfaceOrientation强制)时,它们显示正常 . 但是当我从一个图像选择器的结果代码中调用视图时,portraitview工作得很好,但是这样返回了横向视图 . http://bit.ly/bfbobc .
所以只是说清楚:nob已经转了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];
}
}`
1 回答
如果将子视图添加到视图,则必须自行更改子视图的方向 .
willRotateToInterfaceOrientation
只会调用第一个viewcontroller,因此如果您将Subviews添加到viewcontroller,这可能是您可接受的方式:在您的ViewController中:
在你Subview ViewController:
这可能会让你朝着正确的方向前进 .