【问题标题】:to correctly target delegate if I don't want to create instance and setting delegate in viewDidLoad() but in some method?如果我不想在 viewDidLoad() 中创建实例和设置委托,但在某些方法中,正确定位委托?
【发布时间】:2013-01-29 21:38:52
【问题描述】:

如果我不想在 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];
}

【问题讨论】:

  • 你实现了UIImagePickerControllerDelegate需要的方法了吗? imagePickerController:didFinishPickingMediaWithInfo: 和 imagePickerControllerDidCancel: ?
  • 是的,我写的一切正常,但收到警告并试图找出原因

标签: iphone xcode delegates


【解决方案1】:

确保你已经在你的头文件中包含了两个委托,比如

@interface MyViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多