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 6656811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:41:19+00:00 2026-05-26T01:41:19+00:00

An app i am developing is pulling in custom ads. I’m retrieving ads fine,

  • 0

An app i am developing is pulling in custom ads. I’m retrieving ads fine, and the network side of things are working correctly. The problem I’m having is when the AdController receives an ad it parses the JSON object then requests the image.

// Request the ad information
NSDictionary* resp = [_server request:coords_dict isJSONObject:NO responseType:JSONResponse];
// If there is a response...
if (resp) {
    // Store the ad id into Instance Variable
    _ad_id = [resp objectForKey:@"ad_id"];
    // Get image data
    NSData* img = [NSData dataWithContentsOfURL:[NSURL URLWithString:[resp objectForKey:@"ad_img_url"]]];
    // Make UIImage
    UIImage* ad = [UIImage imageWithData:img];
    // Send ad to delegate method
    [[self delegate]adController:self returnedAd:ad];
}

All this works as expected, and AdController pulls in the image just fine…

-(void)adController:(id)controller returnedAd:(UIImage *)ad{
    adImage.image = ad;
    [UIView animateWithDuration:0.2 animations:^{
        adImage.frame = CGRectMake(0, 372, 320, 44);
    }];
    NSLog(@"Returned Ad (delegate)");
}

The When the delegate method is called, it logs the message to the console, but it takes up to 5-6 seconds for the UIImageView* adImage to animate in. Because of the way the app is handling the request of the ads, the animation needs to be instant.

The animation for hiding the ad is immediate.

-(void)touchesBegan{
    [UIView animateWithDuration:0.2 animations:^{
        adImage.frame = CGRectMake(0, 417, 320, 44);
    }];
}
  • 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-05-26T01:41:20+00:00Added an answer on May 26, 2026 at 1:41 am

    If the ad-loading happens in a background thread (the easiest way to check is [NSThread isMainThread]), then you cannot update the UI state in the same thread! Most of UIKit is not thread-safe; certainly UIViews currently be displayed are not. What’s probably happening is that the main thread does not “notice” the change happening in the background thread, so it’s not flushed to screen until something else happens.

    -(void)someLoadingMethod
    {
      ...
      if (resp)
      {
        ...
        [self performSelectorInMainThread:@selector(loadedAd:) withObject:ad waitUntilDone:NO];
      }
    }
    
    -(void)loadedAd:(UIImage*)ad
    {
      assert([NSThread isMainThread]);
      [[self delegate] adController:self returnedAd:ad];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows 6 app I am developing (in VB). I am pulling
I'm developing app - it is custom offline feed reader. I's completely free, so
While developing my app (asp.net mvc3) locally everything was fine using the VS dev
i am developing app.its having post message on facebook and twitter.i searched on net
I am developing app for iphone and ipad but my biggest problem is to
I'm trying to get into Android app developing. My first problem is actually getting
I have samsung i5503 galaxy. I got a problem in developing app. First I
Greeting, I'm a C# programmer guy. I'm planning to start developing app for iphone
When developing an app that will listen on a TCP/IP port, how should one
While developing my app I have come to realize that the majority of my

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.