ios - How to set view controller inside the scrollview? -
my requirement set multiple view controller in scrollview.
in viewcontroller1's nib file add scrollview subview , make outlet named myscrollview.and set delegates too.then on scrollview add uiview subview , make outlet contentview.
create property viewcontroller named yourviewcontroller (it should have nib file same name).
@property (nonatomic, strong) yourviewcontroller *yourviewcontroller;
in viewdidload of viewcontroller1
self.yourviewcontroller = [yourviewcontroller alloc] initwithnibname:@"yourviewcontroller" bundle:nil]; [self addchildviewcontroller:self.yourviewcontroller];// viewcontroller going add. self.yourviewcontroller.view.frame = self.contentview.bounds; [self.contentview addsubview:self.yourviewcontroller.view]; [self.yourviewcontroller didmovetoparentviewcontroller:self];
Comments
Post a Comment