我使用UIImagePickerController
来拍照。我为 UIApplicationDidBecomeActiveNotification 和 UIApplicationWillResignActiveNotification 注册了一个通知中心
在 MainViewController
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(applicationUIDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[nc addObserver:self
selector:@selector(applicationUIWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
我有 CamController ,它是UIImagePickerController
@interface CamController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
当应用程序变为活动状态时,我将根据MainViewContrller中的代码显示模态视图控制器。
- (void) applicationUIDidBecomeActive: (NSNotification *) aNotification {
// camController is a instance of CamController
[camController displayModalWithController:parentViewController animated:NO];
[camController performSelector:@selector(takePicture) withObject:nil afterDelay:1.5];
}
以下代码位于CamController中,它是UIImagePickerController
- (void) displayModalWithController: (UIViewController*) aController animated: (BOOL) aAnimated {
if (aController)
[aController presentModalViewController:self animated:aAnimated];
}
- (void) takePicture {
[super takePicture];
}
- (void)imagePickerController: (UIImagePickerController *) aPicker didFinishPickingMediaWithInfo: (NSDictionary *) aInfo {
[self performSelector:@selector(takePicture) withObject:nil afterDelay:[self mCapturingInterval]];
}
当应用程序将重新激活时,我会根据MainViewController中的代码关闭模态视图控制器。
- (void) applicationUIWillResignActive: (NSNotification *) aNotification {
[parentViewController dismissModalViewControllerAnimated:NO];
}
我在iphone 4 ios 4.2.1上测试此代码,有时在我重新启动应用程序后, UIImagePicker的视图(显示我们要捕获的图像的视图)被调整为更小, 不再是全屏了。我已经将属性wantsFullScreenLayout设置为YES。 当我单击主页按钮将其置于后台然后单击应用程序图标以再次启动应用程序时,屏幕可能是全屏或 调整大小。这个问题的原因是什么?