I am new in iPhone development.
I have a UIViewController in storyboard that includes a scrollView.
I want to put two UIImageViews and some UILabels on it.
the idea that I am thinking is : create a .xib file. Put a UIView on it, an then set my UIImageview and labels on this UIView.
Finally add my UIView which is a .xib file to my UIScrollView.
Is it a good idea? if not what is your suggestion.
until now I could not make it works. this is my code:
OfferUIView *newPageView = [[OfferUIView alloc] init]; // UIView that I created as .xib
self.newPageView.contentMode = UIViewContentModeScaleAspectFill;
newPageView.frame = frame;
[self.scrollView addSubview:newPageView];
[self.pageViews replaceObjectAtIndex:page withObject:newPageView];
Can you help me?
我知道这听起来很愚蠢,但是您是否尝试self.scrollView
和self.pageViews
删除self
?
How did you created your .xib file? it should be sub class of UIView . Hope you didn't do the mistake of creating it as a sub class of UIViewController.
I found the answer:
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"OfferView" owner:self options:nil];
UIView *newPageView = [views lastObject];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.