我尝试使用 UIImagePickerController 从 iphone 图库中挑选照片。单击按钮时,我执行以下操作:
- (IBAction)attachAction:(id)sender {
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = YES;
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imagePicker animated:YES];
}
在纵向它很好,但是当我旋转到横向时,呈现图像选择器并在做一些工作后将其关闭,父视图控制器的布局中断,我看到一半的屏幕带有父视图和另一半黑色矩形。
任何想法如何解决这个问题?imagePicker 关闭后,如何强制 uiviewcontroller 手动更改布局或其方向?
我尝试通过此代码处理旋转,但没有任何改变
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate
{
return YES;
}
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self.view setNeedsLayout];
}