0

景観を維持したい。そのために私はこのコードを使用していますが、BAD_ACCESS が来ています。ここで、カメラのoverlayView用にこのコードを書いています。

 -(void)viewDidLoad
 {
     [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
     //Set Notifications so that when user rotates phone, the orientation is reset to landscape.
     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
     //Refer to the method didRotate:   
     [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didRotate:)
              name:@"UIDeviceOrientationDidChangeNotification" object:nil];
     [super viewDidLoad];
 }

 - (void) didRotate:(NSNotification *)notification
 {
        //Maintain the camera in Landscape orientation
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
 } 

BAD ACCESS を与えているのはなぜですか?

4

1 に答える 1

4

ビューの横向きを維持するには、 tihs のように縦向きのメソッドをNO返すだけです。shouldAutorotateToInterfaceOrientation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
于 2012-04-10T11:36:55.643 に答える