开发者

why can't I set a new instance's delegate as self?

开发者 https://www.devze.com 2022-12-30 10:33 出处:网络
I have a uipickerview, which appears with an ActionSheet. All this is in a class \"MultiPicker\". I create a new instance from \"FirstViewController\" this way:

I have a uipickerview, which appears with an ActionSheet. All this is in a class "MultiPicker". I create a new instance from "FirstViewController" this way:

multiPicker *multiPic = [[multiPicker alloc]init];
multiPic.delegate = self;

[multiPic action:aRunIndex];

And inside "multiPicker", in "action:"

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title          delegate:otroDelegate cancelButtonTitle:nil destructiveButtonTitle:@"Cancel" otherButtonTitles:@"Done", nil];

 UIPickerView *pickerView = [[[UIPickerView alloc] init] autorelease];
 pickerView.tag = 101;
 pickerView.delegate = self;
 pickerView.dataSource = self;
 pickerView.showsSelectionIndicator = YES;

 [actionSheet addSubview:pickerView];
 [actionSheet showInView:self.view];

I need "FirstViewController" when MultiPicker finishes, so I can update a table in FirstView. I tried setting a new delegate to MultiPicker so, it tells FirstView when it finishes. But the instruction "multipic.delegate = self" in the first piece of code mades the app crash and says "Terminating due to uncaught exception".

If I simply put all "MultiPicker" code inside FirstViewController class, not in a separate one, the action sheet stay blocked when I try to push a button different from "Cance开发者_如何学Pythonl"

Any idea?

Thank u


  1. be sure that your class 'self' implement the require protocol
  2. protocols have optional and required methods you must implement all required methods of delegate 'protocol' in you class 'self'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号