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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:03:59+00:00 2026-05-26T01:03:59+00:00

This is the main view and I’d like to toggle two separated views; for

  • 0

This is the main view and I’d like to toggle two separated views; for ON state and for OFF state.

How the code would look like?

Toggle views with switch controller

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

    Do the following

      - (void)viewDidLoad //of mainViewController {
            //do viewController1 alloc init     // Gray Color
            [self.view addSubview:viewController1.view];
    
            //do viewController2 alloc init     //Red Color
            [self.view addSubview:viewController2.view];
    
            [viewController2.view setHidden:YES];
        }
    

    //assign this method to segmented controls' valueChanged event
        - (IBAction)segmentControlClicked:(id)sender {
            UISegmentedControl *segmentedControl = (UISegmentedControl *)sender; // if segmented control is not declared as an IBOutlet
            if (segmentedControl.selectedSegmentIndex == 0) {
                [viewController1.view setHidden:NO];
                [viewController2.view setHidden:YES];
            }
            else if (segmentedControl.selectedSegmentIndex == 1) {
                [viewController2.view setHidden:NO];
                [viewController1.view setHidden:YES];
            }
        }
    

    Make sure that the ‘y’ origin viewController1 and viewController2 are below the Segmented Control so that the segmented control is not hidden.

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

Sidebar

Related Questions

I have my main view like this: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage %>
I have this code in the main view controller and it is working just
I'm trying to refresh my main view in this code. It shows the right
in the main view i call the ViewB like this viewB=[[ViewB alloc] initWithNib:@ViewB bundle:nil]
This code works (when ControlType=dropDown then the background yellow ): <Window x:Class=TestCollapsed.Views.MainView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
The situation is like this : Main project A. and a class library B.
My program is like this ( main.c ): #include <stdlib.h> #include <stdio.h> void main(){
I've got m2m relationship like this: #main table CREATE TABLE products_product ( id integer
I have a system that runs like this: main.exe runs sub.exe runs sub2.exe and
Code first: '''this is main structure of my program''' from twisted.web import http from

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.