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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:26:16+00:00 2026-05-23T19:26:16+00:00

I have 3 classes. One is the class I show the loading view in(class

  • 0

I have 3 classes. One is the class I show the loading view in(class A), one is the class I want to dismiss the loading view in(class B), and the last is the loading view object itself.

In classA I am able to show the loading view just fine by calling the showLoadingViewWithView: method I have displayed below, however when I get to classB and I want to dismiss that same loading view that I have created nothing happens.

Each method is called by creating an instance of the loading object, allocating memory to it, and then [object methodCall]; then release.

-(void)showLoadingViewWithView:(UIView *)currentView
{
CGRect transparentViewFrame = CGRectMake(0.0, 0.0,320.0,480.0);
loadingView = [[UIView alloc] initWithFrame:transparentViewFrame];
loadingView.backgroundColor = [UIColor grayColor];
loadingView.alpha = 0.9;

loadingSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
loadingSpinner.center = loadingView.center;
[loadingSpinner startAnimating];

UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 180, 320, 30)];
messageLabel.textAlignment = UITextAlignmentCenter;
messageLabel.text = @"Loading Please Wait...";
messageLabel.textColor = [UIColor whiteColor];
messageLabel.backgroundColor = [UIColor clearColor];
messageLabel.font = [UIFont boldSystemFontOfSize:15];

[loadingView addSubview:loadingSpinner];
[loadingView addSubview:messageLabel];

[currentView addSubview:loadingView];

[messageLabel release];
}




-(void)dismissLoadingView
{
[loadingSpinner stopAnimating];
[loadingView removeFromSuperview];
}

Any help would be awesome thanks.

  • 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-23T19:26:16+00:00Added an answer on May 23, 2026 at 7:26 pm

    Specialy when you are dealling with loading views indicators you often show the indicator in one place and need to notify it to close in another place. For this purpose (but not only) you should use NSNotifications. This is how you use it.

    In class A you create a notification observer. Usually in the init method.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeLoadingView:) name:@"CloseLoadingView" object:nil];
    

    Then you need to impelemnt closeLoadingView: method to acctually close the view when the nottification arrives:

    -(void)closeLoadingView:(NSNotification)notification{
      //Close the view
      [loadingSpinner stopAnimating];
      [loadingView removeFromSuperview];
    }
    

    Always remeber to remove observers when you don’t need them. Usualy that happens in the dealloc.

    -(void)dealloc{
       [[NSNotificationCenter defaultCenter] removeObserver:self name:@"CloseLoadingView" object:nil];
    }
    

    Now in class B or from enywhere in your application you can close the view simply by sending a notification

    [[NSNotificationCenter defaultCenter] postNotificationName:@"CloseLoadingView" object:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, and want to include a static instance of one class
I have one abstract class -let's say myBase. And I want all the classes
I currently have 2 concrete methods in 2 abstract classes. One class contains the
I have one abstract class and many child classes. In child classes are from
I have class A and classes B and C. class B runs one thread
I have a class library. In one of the classes, I am adding a
I have the following two classes, one inherits from the other Class A{ void
Let's say I have two models, Classes and People. A Class might have one
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I have two classes one of which inherits from the other. Im trying to

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.