UIScrollView paging load from nib just 1 NIB show
i'm new on object-C, i want show some NIB file to UIScrollView with paging, i'm do it but just 1 NIB showing, other nib not show, the sample i make 2 page on each page have NIB, this is code :
bbottompageused = NO;
CGRect frame;
int tview=2;
mycontact = [[MyContact alloc] initWithNibName:@"MyContact" bundle:nil];
myphoto = [[MyPhoto alloc] initWithNibName:@"MyPhoto" bundle:nil];
frame.origin.x = self.midleScroll.frame.size.width * 1;
frame.origin.y = 0;
frame.size = self.midleScroll.frame.size;
[self.midleScroll addSubview:mycontact.view];
frame.origin.x = self.midleScroll.frame.size.width * 2;
frame.origin.y = 0;
frame.size = self.midleScroll.frame.size;
[self.midleScroll addSubview:myphoto.view];
self.mi开发者_如何学GodleScroll.contentSize = CGSizeMake(self.midleScroll.frame.size.width * tview, self.midleScroll.frame.size.height);
self.midlePage.currentPage = 0;
self.midlePage.numberOfPages = tview;
Have anyone suggestion for solve this ?
Thanks all,assign the frame that you have to your views (myContact, myPhoto) and then add them to the scroll view.
You configure the frame but you don't assign this frame to myContact.view
and myPhoto.view
.
Hence, both of the myContact.view.frame
and myPhoto.view.frame
remain unchanged.
Do the following:
bbottompageused = NO;
CGRect frame;
int tview=2;
mycontact = [[MyContact alloc] initWithNibName:@"MyContact" bundle:nil];
myphoto = [[MyPhoto alloc] initWithNibName:@"MyPhoto" bundle:nil];
frame.origin.x = self.midleScroll.frame.size.width * 1;
frame.origin.y = 0;
frame.size = self.midleScroll.frame.size;
// Assign the frame
myContact.view.frame = frame;
[self.midleScroll addSubview:mycontact.view];
frame.origin.x = self.midleScroll.frame.size.width * 2;
frame.origin.y = 0;
frame.size = self.midleScroll.frame.size;
// Assign the frame
myPhoto.view.frame = frame;
[self.midleScroll addSubview:myphoto.view];
self.midleScroll.contentSize = CGSizeMake(self.midleScroll.frame.size.width * tview, self.midleScroll.frame.size.height);
self.midlePage.currentPage = 0;
self.midlePage.numberOfPages = tview;
精彩评论