2012-04-20 4 views
1
{  
    self.imagePickerController = [[[UIImagePickerController alloc] init ] autorelease]; 
    imagePickerController.view.frame=CGRectMake(0, 0, 1024, 768); 
    self.imagePickerController.delegate = self; 
    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; 

    //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]; 

    //Set the picker source as the camera 
    self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 

    //Bring in the picker view 
    [self presentModalViewController:self.imagePickerController animated:YES]; 
} 
+0

どのような問題がありますか、説明できますか? –

+0

[このリンクを試す] [1] [1]:http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app –

+0

以上実行した後コード私はBAD_Excessを得た –

答えて

-2

が、これはあなた

-(void)cameraAction 
{ 

// Create image picker controller 
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 

// Set source to the camera 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
// Delegate is self 
imagePicker.delegate = self; 

// Allow editing of image ? 

imagePicker.allowsEditing = NO; 


if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
{ 
    // Show image picker 
    [self presentModalViewController:imagePicker animated:YES]; 

} 
else{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing the camera" 
                message:@"Camera did not respond" delegate:nil 
              cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
} 

} 
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
// Access the uncropped image from info dictionary 
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 

    [picker release]; 

    [self dismissModalViewControllerAnimated:NO]; 

    editImageView=[[EditImageViewController alloc] initWithNibName:@"EditImageViewController" bundle:[NSBundle mainBundle]]; 
    editImageView.delegate=self; 
    [self presentModalViewController:editImageView animated:YES]; 
    [editImageView.imgView setImage:image]; 

} 

役立つかもしれないが、これは、カスタムuiimagepickerviewcontrollerはありませんが、あなたは、両方modes.Tryでこれを写真を撮ることができ、これを使用して私のコード..です

+0

質問は、風景の中でカスタムカメラに関するものであり、あなたは両方のモードで写真を撮影することに答えています。また、私は風景モードで画像を取得することはできません。この機能を実行するEditImageViewControllerクラスも投稿する必要があります – Ronak

関連する問題