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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:05:04+00:00 2026-05-26T05:05:04+00:00

In my view-based application,it includes three views.First View(Main View) call second view.Second view call

  • 0

In my view-based application,it includes three views.First View(Main View) call second view.Second view call third view(detail view). I want to add home function in third view to go back first view(Main View).
Currently I add Home button in third view.But I don’t know how to write this function. The following is my code:

//In First view(main view)
//call second view(list view) in button click
-(IBAction) doctorList:(id)sender
{   
    if(self.doctorViewController==nil)
    {
        DoctorViewController *doctorView=[[DoctorViewController alloc] initWithNibName:@"DoctorViewController" bundle:[NSBundle mainBundle]];

        self.doctorViewController=doctorView;
        [doctorView release];
    }

    self.view addSubview:self.doctorViewController.view];}
}

//In second View(list view)
//Call third view in table cell click
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
    DoctorItem *physician=[[DoctorItem alloc]init];
    physician=(DoctorItem*)[self.tableDataList objectAtIndex:indexPath.row];    
    DoctorDetail *detail=[[DoctorDetail alloc]init];[tableView.superview addSubview:detail.view];
    [physician release];
}

In third view,there is a button with label text ‘Home’
When user click this button,I want to add go back to first view(main view). I don’t know how to do that.

  • 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-26T05:05:04+00:00Added an answer on May 26, 2026 at 5:05 am

    I didn’t see any mention of UINavigationControllers in Phoenix’s posting… so if I were fixing this code, I’d create an IBAction method like this:

    - (IBAction) homeButtonPressed: (id) sender
    {
        // and remove the subviews
    
        NSArray * subviews = [self.view subviews];
        for(UIView * aSubview in subviews)
        {
            // this removes and releases the subviews you allocated
            [aSubview removeFromSuperview];
        }
    
    }
    

    and connect your button action to that method.

    Also, I’d recommend subclassing UIView and not UIViewController for DoctorView and DoctorViewController. You don’t need the extra baggage that UIViewControllers bring if you’re just adding subviews onto the root view controller.

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

Sidebar

Related Questions

What Is The Main Difference Between a View-Based Application Template And Window-Based Application Template
I've just created a new view based application, and now I want to set
I have a UITabBar in the detail view of my navigation based application. I
I have an view-based application where the user can do a lot of customization
I've created a new View-based Application in XCode. In the ViewController, the only code
How should I go about creating a NavigationController for use in a view-based application?
i am developing a iphone application in a view-based project,(not navigation) however i would
Need some best practice advice here... Navigation based application. Root view is a UITableView
I have created an iPhone application based on an OpenGL view. Now I would
Consider a normal customer-orders application based on MVC pattern using WinForms. The view part

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.