よくUIImagePickerController
写真を撮ります。MainViewControllerにUIApplicationDidBecomeActiveNotificationとUIApplicationWillResignActiveNotificationの通知センターを登録
します
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 に設定しています。ホームボタンをクリックしてバックグラウンドに戻し、アプリケーションアイコンをクリックしてアプリケーションを再度起動すると、画面が全画面表示またはサイズ変更される場合があります。この問題の原因は何ですか?