ios - Conformance to UIImagePickerControllerDelegate protocol not being seen by the compiler -


i'm missing something. code functions fine, clear compiler warnings.

sending 'gsbbuilderimagebutton *const __strong' parameter of incompatible type 'id<uinavigationcontrollerdelegate,uiimagepickercontrollerdelegate>' 

in past experiences warning message, never noticed two protocols being mentioned in warning -- , fair enough, in case have no idea why there reference uinavigationcontrollerdelegate.

but here's interface first:

#import <uikit/uikit.h> #import "gsbimagebuttondelegate.h"  @interface gsbbuilderimagebutton : uibutton <uiimagepickercontrollerdelegate> {     uipopovercontroller *popover;     uiimage *imagedata;     nsurl *mediaurl;     id <gsbbuilderimagebuttondelegate> _delegate; } @property (strong, nonatomic) nsurl *mediaurl; @property (strong, nonatomic) uiimage *imagedata; @property (strong, nonatomic) id <gsbbuilderimagebuttondelegate> delegate; - (void)removepicture; - (void)setimagedata:(uiimage *)theimagedata;  @end 

of importance @interface declaration includes uiimagepickercontrollerdelegate adoption.

over in implementation pay attention touch (i think @ time wrote wasn't using settarget:foraction:forcontrolstate: because class started life uiview):

- (void)touchesended:(nsset *)touches withevent:(uievent *)event {     // need check see touch ended while within our bounds      uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init];      [imagepicker setsourcetype:uiimagepickercontrollersourcetypesavedphotosalbum];     [imagepicker setsourcetype:uiimagepickercontrollersourcetypephotolibrary];     [imagepicker setdelegate:self]; 

so way read local object, imagepicker, being told it's delegate instance of gsbbuilderimagebutton, in interface declares conforms uiimagepickercontrollerdelegate protocol. seems valid , time. while it's true gsbbuilderimagebutton has own delegate, shouldn't bear on unless i've done wrong.

there's more after that, of course, including implementation of optional protocol method

- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info 

i'm building button programatically, completeness, here's init i'm using:

- (id)initwithframe:(cgrect)frame {     self = [super initwithframe:frame];     if (self) {         // initialization code         [[self imageview] setcontentmode:uiviewcontentmodescaleaspectfill];         uilongpressgesturerecognizer *longpress = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(removepicture)];         [self addgesturerecognizer:longpress];     }     return self; } 

(note: don't hung on definition of setimagedata... that's wrapper method calls uibutton's setimage few other tasks , it's legacy same uiview heritage -- version 2.0 of app i'll override setimage:!

it's warning message says: uiimagepickercontroller's delegate property expects object conforms both uiimagepickercontrollerdelegate , uinavigationcontrollerdelegate protocols. because image picker ui includes navigation controller; methods in protocol optional, don't need implement them if don't need them.

but still need declare conformance both protocols:

@interface gsbbuilderimagebutton : uibutton <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate> 

the rest of code irrelevant compiler warning.


update: here's related tip. if make use of protocol conformance within class' implementation, don't need declare in header file. can declare conformance in class extension in .m file instead:

@interface gsbbuilderimagebutton () <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate> @end 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -