I have an xib file includes a UIView and a UIScrollView.
Inside my UIView, I have another UIView (the while screen in the middle), and I want to add my scrollView to it programmatically.
The reason is one time I want to add a scrollView there and another time I want to add a mapView.
What I did is like this:
CGRect frame = self.view.bounds;
self.scrollView = [[UIScrollView alloc] initWithFrame: frame];
CGSize pagesScrollViewSize = self.view.frame.size;
self.scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * self.pageImages.count, pagesScrollViewSize.height);
I also need to set the delegate for the UIScrollView.
I could not make it work. this is my error:
-[UIScrollView setPageId:]: unrecognized selector sent to instance 0x7dd84e0
2012-10-06 00:56:17.373 testN[3525:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIScrollView setPageId:]: unrecognized selector sent to instance 0x7dd84e0'
I also don’t know where should I connect the scrollView delegate. can you help me?
I can do that successfully by adding a UIScrollView in the interface builder and then set the delegate and file owner from there.
I just should note that since I want to add the UIView to a ViewController in storyboard this code will not work:
I should use: