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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:33:45+00:00 2026-06-09T20:33:45+00:00

I have ViewController_1 with Button_1: @interface ViewController_1 : UIViewController <UITableViewDataSource, UITableViewDelegate> { IBOutlet UIView

  • 0

I have ViewController_1 with Button_1:

@interface ViewController_1 : UIViewController  <UITableViewDataSource, UITableViewDelegate>
{ 
  IBOutlet UIView *secondView;
  UITableView *myTable;
}

- (IBAction)buttonPressed:(id)sender;

All tableView delegate methods are implemented in ViewController_1.m

In ViewController_1.xib I have 2 views (View of ViewController_1 and secondView):
enter image description here

when I touch Button_1 I add secondView as subview with myTable:

- (IBAction)buttonPressed:(id)sender
   {
     [self.view addSubview:secondView];
   }

How can I implement that the secondView with table and its methods (DataSource) have been implemented in a separate class?
Because if I have, for example, 10 buttons??? Then in ViewController_1 will be a lot of code!!!

  • 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-09T20:33:46+00:00Added an answer on June 9, 2026 at 8:33 pm

    I would suggest you to take a SecondViewController and not view. and when you tap on button then navigate it to that SecondViewController. Like as you are saying there are several buttons which in turn leads to hide unhide several other views. then It would be hard for you to manage. And yes there will be lots and lots of coding and flags.

    And if at all you like to add view then you can keep the SecondViewController as UIViewController. Do all the table datasource/delegates methods there and

    while adding it to ViewController_1

    Try the following code

    - (IBAction)buttonPressed:(id)sender
    {
       [self.view addSubview:secondViewController.view];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one ViewController, in this i have added one Custom UIView named as
I have a ViewController and UIWebView created in Interface Builder in it. I fill
Here is my code: Header: #import <UIKit/UIKit.h> @interface ViewController : UIViewController { UIImageView *imageView;
i have trouble with setNeedsDisplay. I have an UIView with a lot of sub
I have a UITableView with some custom cells in it. In these custom cells
I have a CCGLView which is created in Interface Builder. I have a root
I have two xib files and for each it's own class which overrides UIViewController
I have my MainViewController which a UIViewController class, in this view I have a
ViewController.h @interface ViewController : UIViewController{ CFSocketRef s; int connectFlag; } ViewController.m void receiveDataCilent(CFSocketRef cs,
I have a main view controller that consists of 1 button that when tapped,

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.