I am somehow new in iPhone development.
I have a storyboard that includes a ViewController. inside the ViewController, I have a UIScrollView.
I want to add two images and other controls to my scrollView. I read this link, and decide to implement the idea that described as the answer, but not the way he did programmatically.
I create a new .xib
file and then add a UIView to it and add my UIImages and Labels in it.
Now, I want to add this UIView to my UIScrollView in the storyboard. This is my code:
OfferUIView *newPageView = [[OfferUIView alloc] init];
self.newPageView.contentMode = UIViewContentModeScaleAspectFill;
newPageView.frame = frame;
[self.scrollView addSubview:newPageView];
[self.pageViews replaceObjectAtIndex:page withObject:newPageView];
It does not work for my UIView which is a .xib file, but simply if I add for instance a UIImageView like:
UIImageView *newPageView = [[UIImageView alloc] initWithImage:image];
self.newPageView.contentMode = UIViewContentModeScaleAspectFill;
newPageView.frame = frame;
[self.scrollView addSubview:newPageView];
[self.pageViews replaceObjectAtIndex:page withObject:newPageView];
Then it perfectly works. So how can I fix my code to add .xib file?