簡體   English   中英

如果我不想創建實例並在viewDidLoad()中設置委托但以某種方法正確定位委托,該如何正確定位?

[英]to correctly target delegate if I don't want to create instance and setting delegate in viewDidLoad() but in some method?

如果我不想在viewDidLoad()中創建實例並在某種方法中設置委托,如何正確定位委托? 一切正常,但收到警告。

// ViewController.m    
// Warning: Assigning to 'id'<UINavigationControllerDelegate,UIImagePickerControllerDelegate> from incomplatible type 'ViewController *const __strong

-(void)takeMedia:(UIButton *)sender
{  
  mypicker = [UIImagePickerController new];
  mypicker.delegate = self; // <<<----
  mypicker.sourceType = UIImagePickerControllerSourceTypeCamera;
  [self presentViewController:mypicker animated:YES completion:nil];
}

確保您在頭文件中都包含了兩個委托,例如

@interface MyViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM