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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:46:57+00:00 2026-05-27T18:46:57+00:00

I have a segment control added to the navigation bar. It works fine. When

  • 0

I have a segment control added to the navigation bar. It works fine. When i click on a segment (say index 0) it should load UIView A for me. and when i click on segment 1 it should load UIView B for me.

I have initialized UIVIew A in my .h file. and i am accessing it in the .m file as follows;

Here i am adding a Button and a label to View A

UIButton *buttonAdded= [UIButton buttonWithType:UIButtonTypeRoundedRect];
    signUpButton.frame = CGRectMake(100, 100, 300, 50);
......

[self.viewA addSubview:buttonAdded]; 
// similarly added a label too
[self.viewA addSubview:labelAdded]; 

Now i added another Button and a Label to View B as the previous code;

// i have not shown how to declare a button and label, coz its same as above
[self.viewB addSubview:buttonAddedB]; 
[self.viewB addSubview:labelAddedB]; 

EDIT: I ADDED BOTH THESE VIEWS (View A & View B) IN THE VIEWDIDLOAD METHOD.

The problem is that when i click the segments nothing appears on the screen. Can someone please help me modify the code so it will work ?

  • 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-27T18:46:57+00:00Added an answer on May 27, 2026 at 6:46 pm

    Your viewA and viewB are NULL.

    You have not allocated/initialized your viewA. There needs to be code somewhere that either hooks up a view from your nib (an IBOutlet), or you need something like this:

     UIView *viewA = [[UIView alloc] initWithFrame:CGRectMake(x,y,width,height)];
    

    Then you can use viewA.

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

Sidebar

Related Questions

i have used segment control for distance measuring in km or Miles so if
It would be relatively straightforward to replace the tab bar with a segment control,
I've got a segmented control embedded within a TableViewCell: https://i.stack.imgur.com/4XFML.jpg It works fine on
I have made a segment control. In that there is three segments.. Now I
I have the following segment of code where m_edit is a CEdit control: TCHAR
I have four subview and when I select (segment ==1) in segmented control other
I have some problem implementing a segment control. Because i want it to be
I have a custom cell and i am adding a segment control to it.
I have two points (a line segment) and a rectangle. I would like to
I have two identical byte arrays in the following segment of code: /// <summary>

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.