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

  • SEARCH
  • Home
  • 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 8540413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:35:25+00:00 2026-06-11T11:35:25+00:00

I try to assign an image loaded via [UIImage imageWithData: [NSData dataWithContentsOfURL:imageUrl]]; to my

  • 0

I try to assign an image loaded via

[UIImage imageWithData: [NSData dataWithContentsOfURL:imageUrl]];

to my navigationbar.
Here is what i have:

   //Loading Image from Url and adding it to navigationbar
    NSString *urlString = [NSString stringWithFormat:@"http://someurl.com/%@.gif",imageId];
    NSURL *imageUrl = [NSURL URLWithString:urlString];
    UIImage *myImage = [UIImage imageWithData: [NSData dataWithContentsOfURL:imageUrl]];
    UIButton* button = (UIButton *) myImage;
    UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.rightBarButtonItem = buttonItem;

This works as long as i take a local image and allocate the image view like this:

UIButton* button = (UIButton *) [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myLocalImage.png"]];

The error i get is:
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIImage _setAppearanceIsInvalid:]: unrecognized selector sent to instance 0x6876df0’

Anybody can help? (Or is this too nasty of a hack anyway?)
Thanks a lot!

Ps: heres the original question for the adding image to navigation bar: how to display an image in the navigation bar of an iPhone application?

Edit:
Theres an error in the code:
Should be like this i guess:

UIButton* button = (UIButton *) [[UIImageview alloc] initWithImage:myImage];

Anyway, i dont get an error anymore now, but the image does not appear…

  • 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-11T11:35:26+00:00Added an answer on June 11, 2026 at 11:35 am

    This should work asynchronously

    UIButton *button = [UIButton alloc] init];
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; 
    self.navigationItem.rightBarButtonItem = barButtonItem;
    
    __block UIImage *image;
    // create a dispatch queue to download your image asynchronously
    dispatch_queue_t downloadQueue = dispatch_queue_create("image downloader", NULL);
    // show network activity indicator
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
     dispatch_async(downloadQueue, ^{
            image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageUrl]];
            // dispatch to the main queue
            dispatch_sync(dispatch_get_main_queue(), ^{
                    // set your button's image
                    [button setImage:image forState:UIControlStateNormal];
                });
            }
    });
        dispatch_release(downloadQueue);
    // hide network activity indicator
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to load an image in imgQInput (which is a TImage), assign it
I upload an image with AsyncFileUpload control. On UploadedComplete I try to assign some
I am trying to get a UIImage from a texture I loaded into EAGLView
I try to load an uiimageview from the maindelegate so i can assign it
I facing a weird problem here. I already have a simple try-out for jquery
When,i try to assign null value to my pointer,it sometimes crashes on that line.
I simply try to assign a background color to each div. it looks simple
I would like to try to assign a variable value to input hidden field
I need to find the text 'ifeq ($(Param1)' using grep. I try to assign
i.e. if I create a VARCHAR(50) field, what happens if I try to assign

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.