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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:51+00:00 2026-05-26T04:58:51+00:00

first of all: my question is very theoretical. Even if I post an example,

  • 0

first of all: my question is very theoretical. Even if I post an example, I just want to know which implementation is the best one to solve this kind of problem. Maybe you will laugh when you read this question because it is very fundamentally – but I want to understand how to deal with such a situation.

Imagine the following: You have got an application which communicates with an extern API via XML. As a fact of this the view cannot appear immediately, because the API needs time to react. My idea was to implement a subview which contains a loading animation. When the API sends a response this subview is removed and the main view appears. Here is my example:

- (void)viewWillAppear:(BOOL)animated {

    UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
    [myView setBackgroundColor:[UIColor whiteColor]]; 
    myView.tag = 1;

    UIActivityIndicatorView  *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    loadingView.frame = CGRectMake(145, 160, 25, 25);

    [myView addSubview:loadingView];
    [self.view addSubview:myView]; 
    [loadingView startAnimating];

}

- (void)viewDidAppear:(BOOL)animated
{

    [self loadXMLData]; 
    [self.tableView reloadData]; 
    [[self.view viewWithTag:1] removeFromSuperview]; 
}

Everthing works fine. My problem is the following: it’s not only this view where I have to do that. My applications consists of many views, so what is the best way to avoid repeating this code? I thought about following: I modify the (UIKit UIViewController) viewDidAppear selector and put the code in it. I don’t know if Apple allows to change their frameworks. Furthermore it looks very dirty to me ;o) Is someone able to tell me how this is usually done? Thank you!

( hope you understand me, my first language is not English 🙁 )

  • 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-26T04:58:51+00:00Added an answer on May 26, 2026 at 4:58 am

    Why not just make a subclass of UIViewController which has this code implemented in viewWillAppear and viewDidAppear, and then inherit every other view controller in the application from this “base” subclass rather than UIViewController? That will be much easier than trying to do anything to UIViewController directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very basic magento question i guess. I want to first get all
First of all, I want to say sorry for this very big question, but
First off all my question is which layout is supported by the HTC EVO
The Disclaimer First of all, I know this question (or close variations) have been
First of all, the question is very simple, but I have tried to look
first question answered very quickly, thanks to all. here is the issue, for a
Background First of all, much gratitude to atebits for their very informative blog post
First of all, I would like to apologise if my question is very basic
First of all, please bare my ignorance. This may be a very basic question.
I have got a lengthy question to ask. First of all Im still very

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.