I am trying to make a Tab Bar application where one of the ViewController contains a UIToolbar with a UISegmentedController. The problem I have run into is setting up the UISegmentedController to switch between two views, for the views I am trying to switch between are subclasses of UIWebView and I would like to have them in separate files. (e.g. not just setting up the two views in “-viewDidLoad” of the ViewController.
The code of the method in the ViewController looks like:
- (IBAction)segmentedControlChanged
{
switch (segmentedControl.selectedSegmentIndex)
{case 0:
[self.view addSubview:videosView];
[imagesView removeFromSuperview];
NSLog(@"1");
break;
case 1:
[self.view addSubview:imagesView];
[videosView removeFromSuperview];
NSLog(@"2");
break;
default:
break;
}
Where I have the videosView.h, videosView.m, imagesView.h, and imagesView.m imported in at the top of this document and set up as subclasses of UIWebView.
The errors I am getting seem to indicate that its not accepting imagesView or VideosView in the addSubview and also that removeFromSuperview is not a known class method.
Thanks in advance!
1- A UIViewController does not respond to
removeFromSuperview, a UIView does2-
addSubviewrequired a subclass ofUIViewto be passed to it, not aUIViewController