2011-11-15 17 views
2

UiImagepickerコントローラインタフェースをカメラモードとビデオモードの両方で表示するにはどうしたらいいですか?UIImagePickerControllerを使用して同じデフォルトのカメラアプリケーションを表示する

またはキャンセルボタン(カメラビューに表示されます)を削除して別のボタンに置​​き換える方法。リンゴがこのアプローチを承認するかどうか、それは可能でしょうか?

私を助けてください?

答えて

1

この方法で試すことができます。

BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]; 


    if(hasCamera){ 

     UIActionSheet *actionSheet; 

     actionSheet = [[[UIActionSheet alloc] initWithTitle:@"Add Photo" 
                delegate:self 
              cancelButtonTitle:@"Cancel" 
            destructiveButtonTitle:nil 
              otherButtonTitles:@"Select from Library", @"Take a New Photo", nil] autorelease]; 

     actionSheet.actionSheetStyle = UIBarStyleBlackOpaque; 

     [actionSheet showInView:[self view]]; 
    } 

    else { 

     UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init]; 
     imagePickerController.allowsEditing = YES; 
     imagePickerController.delegate   = self; 

     imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

     [self presentModalViewController:imagePickerController animated:YES]; 

     [imagePickerController release]; 

    } 

Actionsheetのデリゲートメソッド

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 

    //BOOL        hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]; 
    UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init]; 
    imagePickerController.allowsEditing = YES; 
    imagePickerController.delegate   = self; 

    if(buttonIndex == 0) 
    { 
     imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

    } 
    else if(buttonIndex == 1) 
    { 
     imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 

    } 
    [self presentModalViewController:imagePickerController animated:YES]; 

    [imagePickerController release]; 
} 

画像ピッカーのデリゲート

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo 
{ 
    if(image) 
    { 
     [self.addPhotoButton setBackgroundImage:image forState:UIControlStateNormal]; 
    } 
    [picker dismissModalViewControllerAnimated:YES]; 

} 


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 
{ 
    [picker dismissModalViewControllerAnimated:YES]; 

} 
+0

- 私はカメラの画面でユーザにフォトライブラリのオプションを示したいと思います。デフォルトのiPhone Camera Appと同じです。最後のオプションは、オーバーレイプロパティを使用してすべてのものをカスタマイズすることです。カスタマイズしなくてもこの機能を実現できればよいでしょう。 –

関連する問題