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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:44:14+00:00 2026-06-01T15:44:14+00:00

In my iPhone app, I have two UIViewcontroler class firstView and secondView. From the

  • 0

In my iPhone app, I have two UIViewcontroler class firstView and secondView.

From the firstView, I am presenting secondView using presentModalViewController:animated: method.

Problem is that when I am dismissing secondView, I want to hide button in firstView.

Although It does execute the code in firstView [button setHidden:YES];, but still it does not hide the button.

What could be wrong?

  • 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-01T15:44:16+00:00Added an answer on June 1, 2026 at 3:44 pm

    Hope you have declared property and synthesized the IBOutlet button.

    Make an object of FirstViewController in SecondViewController.h and property and synthesize it.

    SecondViewController.h

    @interface SecondViewController {
    .
    .
    FirstViewController *firstView;
    .
    .
    }
    @property (nonatomic,strong) FirstViewController *firstView;
    
    @end
    

    SecondViewController.m

    @implementation SecondViewController 
    .
    .
    @synthesize firstView;
    .
    .
    @end
    

    Now when you present a modal view from firstView

    FirstViewController.m

    -(IBAction)presentModalView {
        SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
        secondView.firstView = self;
        [self presentModalViewController:secondView animated:YES];
    }
    

    Now in SecondViewController where you dismiss SecondViewController just add this code.

    SecondViewController.m

    -(IBAction)dismissModalView {
        [self.firstView.button setHidden:YES];
        [self dismissModalViewControllerAnimated:YES];
    }
    

    EDIT:

    Refer to this link:

    @protocol implementation in @interface in Objective-C

    EDIT-2: With Protocol implementation

    SecondViewController.h

    @protocol SecondViewControllerDelegate <NSObject>
    @required
        - (void)hideButton;
    @end
    
    @interface SecondViewController {
    .
    .
    id <SecondViewControllerDelegate> delegate;
    .
    .
    }
    @property (retain) id delegate;
    
    @end
    

    SecondViewController.m

    @implementation SecondViewController 
    .
    .
    @synthesize delegate;
    .
    .
    @end
    

    Now when you present a modal view from firstView

    FirstViewController.h

    #import <UIKit/UIKit.h>
    
    @interface FirstViewController : UIViewController<SecondViewControllerDelegate>
    {
    .
    .
    .
    .
    }
    .
    .
    @end
    

    FirstViewController.m

    -(IBAction)presentModalView {
        SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
        secondView.delegate = self;
        [self presentModalViewController:secondView animated:YES];
    }
    
    #pragma mark - SecondViewController Delegate
    
    - (void)hideButton
      {
          [self.button setHidden:YES]; //Here button is UIButton you want to hide when second view is dismissed.
      }
    

    Now in SecondViewController where you dismiss SecondViewController just add this code.

    SecondViewController.m

    -(IBAction)dismissModalView {
        [delegate hideButton];
        [self dismissModalViewControllerAnimated:YES];
    }
    

    Let me know if you need more help on this.

    Hope this helps.

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

Sidebar

Related Questions

I'm using sqlite as a datasource in an iPhone app. I have two questions
I actually have two questions regarding exception/error handling in the iPhone app that I
In my iPhone app, I have two plist files to store Themes. One is
In my iPhone app I have two viewControllers: viewController1 has a tableView that shows
Say I have two NSTimers in my iPhone app: timer1 and timer2 . timer1
In my IPhone app I have a UITableView. I want two buttons to appear
In my iPhone app I am developing, I have defined two windows: @interface The_NoteAppDelegate
I am learning iOS and I have written a simple iPhone app using iOS
I'm currently developing an iPhone app where I have two UITextField's in one View
I'm having some trouble with an iPhone app that I'm making. I have two

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.