MyPLayer という Cocoa Touch クラスを作成します。
MyPLayer.h
@interface MyPLayer : NSObject<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
その中にピッカービューを作成します。
MyPlayer.m
@implementation MyPLayer
SINGLETON_GCD(MyPLayer);
ビデオ キャプチャを開始するメソッド:
+ (void)startCaptureVideoFromViewController:(UIViewController *)controller videoUploadProgressionHandler:(VideoUploadProgressionBlock)videoUploadProgressionBlock videoSavedHandler:(VideoSavedBlock)videoSavedBlock videoCanceledHandler:(VideoWasCanceledBlock)videoCanceledBlock captureFailedHandler:(FailDetailsBlock)failBlock {
id <UIImagePickerControllerDelegate, UINavigationControllerDelegate> delegate = [MyPlayer sharedInstance];
そして、ライブラリ内の UIPickerViewController で、デリゲートを設定しました
picker.delegate = delegate;
picker.mediaTypes と picker.cameraDevice を定義した後、UIToolbar を作成し、その中にボタンを作成します。
UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, [dadosUsuario doubleForKey:@"toolBarHeigh"]-54, [dadosUsuario doubleForKey:@"toolBarWidth"], 55)];
toolBar.barStyle = UIBarStyleBlackOpaque;
NSArray *items=[NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(shootVideo)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
nil];
[toolBar setItems:items];
UIViewController で MyPlayer を呼び出し、メソッドを呼び出して UIPickerView を表示します。オーバーレイとボタンが表示されます。しかし、UIToolbar の @selector に一致するメソッドをどこで作成できますか?
すべての UIPicker Delegate メソッドは MyPLayer 内にありますが、UIBarItem を起動できません。これはデリゲートか何かが原因だと思います。
このすべてのコード (ピッカー ビュー、uibaritem、およびセレクター メソッド) を通常の UIViewController で宣言すると、これは正常に機能します。