Search code examples
ios6

Different sections in a view in iOS


I want to achieve something like the next image at the bottom. Three sections which I can change touching in each option (Descripción, Video and Afiche). I don't know which UI components should I use according to iOS patterns and components. My workaround to achieve it would be use three buttons and when the user touch any of them I should hide the current view and show other view. Should I do my workaround or do you have any other suggestion? I'm developing from iOS 7. Thanks.

enter image description here


Solution

  • My solution was to use a UISegmentedControl to switch between views. I'm using a WebView and when user change between options I just change the WebView's content.

    1. Assign selector to the UISegmentedControl

      [_segmentControl addTarget:self action:@selector(segmentedControlClicked:) forControlEvents:UIControlEventValueChanged];

    2. Method to change between views

      -(IBAction)segmentedControlClicked:(id)sender { if([sender selectedSegmentIndex]== 0 ) { [_webViewContent loadHTMLString:desc baseURL:nil]; } else if ([sender selectedSegmentIndex] == 1) { [_webViewContent loadHTMLString:html baseURL:nil]; } else if([sender selectedSegmentIndex] == 2) { [_webViewContent loadHTMLString:desc baseURL:nil]; } }