Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8063057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:53:35+00:00 2026-06-05T10:53:35+00:00

I’m missing something. This code functions fine, but I like to clear up all

  • 0

I’m missing something. This code functions fine, but I like to clear up all compiler warnings.

Sending 'GSBBuilderImageButton *const __strong' to parameter of incompatible type 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>'

In past experiences with this warning message, I never noticed two protocols being mentioned in the warning — and fair enough, in this case I have no idea why there is a reference to a UINavigationControllerDelegate.

But here’s my 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 is the @interface declaration which includes the UIImagePickerControllerDelegate adoption.

Over in my implementation I pay attention to a touch (I think at the time I wrote this I wasn’t using setTarget:forAction:forControlState: because this class started life as a UIView):

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    // really need to check to see that the touch ended while within our bounds

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

    [imagePicker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [imagePicker setDelegate:self];

So the way I read that is that the local object, imagePicker, is being told that it’s delegate is this instance of a GSBBuilderImageButton, which in its interface declares that it conforms to the UIImagePickerControllerDelegate protocol. That seems perfectly valid and something we do all the time. While it’s true that my GSBBuilderImageButton has its own delegate, that shouldn’t bear on this unless I’ve done something wrong.

There’s more after that, of course, including implementation of the optional protocol method

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

I’m building this button programatically, so for completeness, here’s the 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 get hung up on my definition of setImageData… that’s a wrapper method that calls UIButton’s setImage but also a few other tasks and it’s legacy is the same UIView heritage — for version 2.0 of this app I’ll override setImage:!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:53:37+00:00Added an answer on June 5, 2026 at 10:53 am

    It’s just what the warning message says: UIImagePickerController‘s delegate property expects an object which conforms to both the UIImagePickerControllerDelegate and UINavigationControllerDelegate protocols. This is because the image picker UI includes a navigation controller; the methods in that protocol are optional, so you don’t need to implement them if you don’t need to do anything with them.

    But you do still need to declare conformance to both protocols:

    @interface GSBBuilderImageButton : UIButton <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
    

    The rest of your code is irrelevant to the compiler warning.


    Update: Here’s a related tip. If you make use of protocol conformance only within your class’ implementation, you don’t need to declare it in the header file. You can declare conformance in a class extension in your .m file instead:

    @interface GSBBuilderImageButton () <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.