0

I'm calling the following code fragment to swap a view.(on top of screen, there's a UISegmentedControl to switch views)

SomeViewController* vc = [[SomeViewController alloc] init];
self.view = vc.view;

When user can switch back to original view by clicking the first button on the UISegmentedControl.

How should I recreate the view?

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
eugene
  • 39,839
  • 68
  • 255
  • 489
  • if i m not wrong you should try to make singleton type of view, so you can achieve again as you left it. – SachinVsSachin Nov 01 '12 at 05:33
  • i just give an idea that just hide and show the SomeViewController on segmentbutton click event.. and add as a subview of you main view.. – Paras Joshi Nov 01 '12 at 05:36

1 Answers1

0

just for an example and for one idea if you use this bellow logic then its very easy to fullfil your requirement..

add as a subview of your self.view in viewDidLoad: method and hide it...

- (IBAction)segmentedControlChangedValue:(id)sender{
    if (segmentedControl.selectedIndex == 0) {
        vc.hidden = YES;
    }
    else if (segmentedControl.selectedIndex == 1) {
        vc.hidden = NO;
        [self.view bringSubviewToFront:vc];
    }
}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70