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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:47:07+00:00 2026-05-17T14:47:07+00:00

I have an iPhone app with a main view that has a UILabel and

  • 0

I have an iPhone app with a main view that has a UILabel and a UIButton. When the button is clicked, I display a second view. The second view has a text box and an OK button.

I want the user to enter something in the second view’s text box and then click the OK button; this should close the second view and apply the entered text to the UILabel back on the first view.

How can I expose the contents of the text box on the second view, and how do I access this from the first view? Also, how can I get the OK button on the second view to close the view (i.e. navigate back to the first view)?

Update: Since I’m coming from the .NET world, I can describe how I would do this same task in .NET, and that might make it clearer what I’m trying to do. In a .NET application, I would create a form (with the text box and button), and then display it using ShowDialog, which presents the form modally. I would add a public property to the form (called EnteredText or something) which returns whatever is in the text box. When my calling code continues from the ShowDialog call, I simply read the form’s EnteredText property and use it however, then dispose of the form.

I’m trying to do basically the same thing with an iPhone app.

  • 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-17T14:47:08+00:00Added an answer on May 17, 2026 at 2:47 pm

    Create a delegate protocol and assign the first view to be a delegate of the second view. Then add a method to the main view that conforms to the protocol.

    Delegate class (myDelegate.h) would look something like this:

    #import <Foundation/Foundation.h>
    @protocol myDelegate
    - (void) textContent:(NSString *)text;
    @end
    

    Then you add this to the second view header file:

    #import "myDelegate.h"
    @interface secondView : UIView {
    
    id <myDelegate> delegate;
    }
    @property (nonatomic,retain) id <myDelegate> delegate;
    

    And to your second views implementation:

    @synthesize delegate;
    

    Then your main view (header):

    #import "myDelegate.h"
    
    @interface mainView: UIView <myDelegate> {
    
    }
    

    Then in your implementation for your mainview you’ll need to implement the method

    - (void) textContent:(NSString *)text {
    //Do something
    }
    

    Also when you open your second view from your main view you’ll need to set the delegate with:

    [secondView setDelegate:self];
    

    Lastly, when your button is clicked call the delegate method (ie. talk to the main view):

    [delegate textContent:string];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a regular old iPhone app that has a main view controller that
I have an iPhone app that hides the status bar. However, my main view
I have an iPhone app that I am writing and it has 2 targets
In my iPhone app I have a UIViewController that has a UITableView and another
I have an iPhone app that I've built for the app store. Before I
I have an iPhone app that allows users to record videos and I'd like
I have an iphone app i want that befor moving to next screen it
I have an iPhone app running in the simulator that won't quit. I also
I have an iPhone app that heavily relies on the OpenCV library; as such,
I have an iPhone app that is based on a navigation controller. I have

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.