I am trying to create an array of views that I can then swipe though in my applicant.
I have tried to set up my array in my view did load then load the first view in the array into view.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"Prototype";
//Initalizse the swipe gestuer listener
[self setupLeftSwipeGestureRecognizer];
[self setupRightSwipeGestureRecognizer];
//alloc and init viewcontroller nibs
self.detailViewA = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
self.detailViewB = [[DetailViewControllerB alloc]initWithNibName:@"DetailViewControllerB" bundle:[NSBundle mainBundle]];
self.detailViewC = [[DetailViewControllerC alloc]initWithNibName:@"DetailViewControllerC" bundle:[NSBundle mainBundle]];
// Create Array
viewArray = [NSArray arrayWithObjects:detailViewA_, detailViewB_, detailViewC_, nil];
// set detail View as first view
[self.view addSubview:[viewArray objectAtIndex:0]];
}
After which it crashes. and produces this message.
2012-05-31 10:06:33.769 SMPrototypeB[2394:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController superview]: unrecognized selector sent to instance 0x131b00'
You are adding a view controller as a subview but what you need to do is add the view of that viewController.