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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:45:42+00:00 2026-06-10T13:45:42+00:00

Inside my viewDidLoad method, I am applying a loading image that appears until a

  • 0

Inside my viewDidLoad method, I am applying a “loading image” that appears until a webView had completed loading. I would like to specify a different loading image depending on which orientation (portrait or landscape) the iPad is in.

I found this page which is what I based my code from.

My code is shown below. (this is all contained within my viewDidLoad method). This only works in Portrait mode at the moment. Any idea why my landscape code isn’t being called? Please help!

//detect if iPad    
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//if in Portrait Orientation
            if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) {
                loadingImage = [UIImage imageNamed:@"webView-load-image-Portrait~ipad.png"];
                loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
                loadingImageView.animationImages = [NSArray arrayWithObjects:
                                                    [UIImage imageNamed:@"webView-load-image-Portrait~ipad.png"],
                                                    nil];
            }
//if in Landscape Orientation
            if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft
               || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
                loadingImage = [UIImage imageNamed:@"webView-load-image-Landscape~ipad.png"];
                loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
                loadingImageView.animationImages = [NSArray arrayWithObjects:
                                                    [UIImage imageNamed:@"webView-load-image-Landscape~ipad.png"],
                                                    nil];
            }

        }

UPDATE

I know you’re supposed to be able to use image file name modifiers so that the device will automatically pull the correct image. I have tried putting webView-load-image.png in my app images folder with all the correct extensions (and removing the -Portrait~ipad from the file name):

  • webView-load-image~iphone.png
  • webView-load-image@2x~iphone.png
  • webView-load-image-Landscape~ipad.png
  • webView-load-image-Landscape@2x~ipad.png
  • webView-load-image-Portrait~ipad.png
  • webView-load-image-Portrait@2x~ipad.png

and it is still not working 🙁

  • 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-10T13:45:43+00:00Added an answer on June 10, 2026 at 1:45 pm

    I figured it out myself. Here’s what worked for me in case anyone else is having the same issue:

    //ViewController.h
    @interface ViewController : GAITrackedViewController {
        // ...other code
        UIImage *loadingImage;
    }
    
    @property(nonatomic, strong) UIImageView *loadingImageView;
    
    
    //ViewController.m
        - (void)viewDidLoad
        {
            [super viewDidLoad];
    
            ...bunch of other code....
    
        // Subscribe to device orientation notifications, and set "orientation" - will return a number 1-5, with 5 being "unknown".
            [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
            UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation;
    
        //**************** Start Add Static loading image  ****************/
            //if iPhone
            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
            loadingImage = [UIImage imageNamed:@"webView-load-image~iphone.png"];
            loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
                loadingImageView.animationImages = [NSArray arrayWithObjects:
                                                    [UIImage imageNamed:@"webView-load-image~iphone.png"],
                                                    nil];
            }
    
           if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
               if(orientation == 3 || orientation == 4) {
                   loadingImage = [UIImage imageNamed:@"webView-load-image-Landscape~ipad.png"];
                   loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
                   loadingImageView.animationImages = [NSArray arrayWithObjects:
                                                       [UIImage imageNamed:@"webView-load-image-Landscape~ipad.png"],
                                                       nil];
                   NSLog(@"Set webView-load-image iPhone Landscape");
    
               }
               if(orientation == 5) {
                   NSLog(@"Set webView-load-image UNKNOWN");
               }
               if(orientation == 1) {
                    loadingImage = [UIImage imageNamed:@"webView-load-image-Portrait~ipad.png"];
                    loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
                    loadingImageView.animationImages = [NSArray arrayWithObjects:
                                                        [UIImage imageNamed:@"webView-load-image-Portrait~ipad.png"],
                                                        nil];
                    NSLog(@"Set webView-load-image iPad Portrait");
                }
    
    
            }
    
            [self.view addSubview:loadingImageView];
            // End Add Static loading image
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading image in a view's ViewDidLoad() method like this: imgMonthGraph.Image = UIImage.FromFile(A.png); (where
I am creating a MKMapView in a method named generateMap. From inside viewDidLoad, this
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
I have an image view that is inside of a UIScrollView so that I
yeah! i have written the code inside viewDidLoad method but work properly!!! my prolblem
I would like to create a scrollview inside of another view. I put a
I'm trying to call a method inside my viewDidLoad method. How can I do
I have a class that implements UIView and inside - (void)drawRect:(CGRect)rect method I add
Using storyboard ,I created a project. Inside viewDidLoad ,I did : NSLog(@"%@",self.view.description); I got
Inside my Controller i have function that runs after user clicks on item, which

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.