I read the Apple docs, and I scrolled through these forums, and I (successfully) did some tutorials and made my own delegates, but I still didn't understand anything. I am sure that this is what I am disconnecting, but since I did the due diligence and still do not know what I am doing wrong, I was hoping that one of you could tell me.
Situation:
I have a custom UITableViewCell that has a button in it. When the button is pressed, I try to pull out the UIImagePickerController delegate form of this custom cell. I can catch and respond to a button click without a problem, but the thread never goes to the delegate method. In other words, when I look at the code, everything is fine until I try to switch from the target button method to the delegate method in the second class. It is simply not called.
Here is the code.
In the interface file for the custom cell, I set the identifier for the delegate, set the IBOutlet for UIButton, and set the protocol method:
UIButton connects to the getAPic method in IB.
In the implementation file for the custom cell, I put this method that the UIButton objects are aimed at and tries to call the delegate method in the delegate:
In the delegate class interface, I set it as a delegate for the user cell:
@interface DelegateClass : UIViewController < ... CustomPicCellDelegate> { ...
In the delegate class implementation, I am trying to pull out a UIImagePickerController:
- (void)getPhoto { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:picker animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo (NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; }
I canβt understand why the delegate never calls! Please understand, I'm sure I missed something, but I met with documents and these forums many times, and I can not find what I am doing wrong. I use delegates very well in other parts of the code. This one place does not work. Can someone show me that I'm fat? Thanks
objective-c uitableview uibutton delegates
addzo
source share