ios - UIPageViewController not resizing its child view controllers on rotation -


i trying use uipageviewcontroller view controllers added it, problem if launch app in portrait mode appears this:

enter image description here

but if rotate device landscape mode appears this:

enter image description here

though pagination control has resized properly, view of added view controller has not resized properly.

below code have used add respective view controller root view controller in appdelegate:

pagescontainerviewcontroller = [[rwpagescontainerviewcontroller alloc] initwithnibname:@"rwpagescontainerviewcontroller" bundle:nil]; [pagescontainerviewcontroller loadpaginationcontrolatindex:0]; self.window.rootviewcontroller = pagescontainerviewcontroller; 

here implementation of loadpaginationcontrolatindex method:

- (void)loadpaginationcontrolatindex:(rwpaginationview)viewindex {     _pagecontroller = [[uipageviewcontroller alloc] initwithtransitionstyle:uipageviewcontrollertransitionstylescroll navigationorientation:uipageviewcontrollernavigationorientationhorizontal options:nil];      firstviewcontroller *firstviewcontroller = [[firstviewcontroller alloc] initwithnibname:@"firstviewcontroller" bundle:nil];     secondviewcontroller *secondviewcontroller = [[secondviewcontroller alloc] initwithnibname:@"secondviewcontroller" bundle:nil];     thirdviewcontroller *thirdviewcontroller = [[thirdviewcontroller alloc] initwithnibname:@"thirdviewcontroller" bundle:nil];      _subviewcontrollers = @[firstviewcontroller, secondviewcontroller, thirdviewcontroller];      [self.pagecontroller setviewcontrollers:@[_subviewcontrollers[viewindex]] direction:uipageviewcontrollernavigationdirectionforward animated:yes completion:nil];      [self addchildviewcontroller:self.pagecontroller];     [[self view] addsubview:[self.pagecontroller view]];      uiview *insertedview = self.pagecontroller.view;     insertedview.translatesautoresizingmaskintoconstraints = no;     self.view.translatesautoresizingmaskintoconstraints = no;      [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:|[insertedview]|"                                                                       options:0                                                                       metrics:nil                                                                         views:nsdictionaryofvariablebindings(insertedview)]];     [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|[insertedview]|"                                                                       options:0                                                                       metrics:nil                                                                         views:nsdictionaryofvariablebindings(insertedview)]];      [self.view layoutifneeded];      self.pagecontroller.datasource = self; } 

am missing anything? please suggest.

when application loads or when view loads:

[[uidevice currentdevice] begingeneratingdeviceorientationnotifications]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(orientationchanged:) name:uideviceorientationdidchangenotification object:[uidevice currentdevice]]; 

then add following method:

- (void) orientationchanged:(nsnotification *)note {    [self.pagecontroller setviewcontrollers:@[_subviewcontrollers[currentindex]] direction:uipageviewcontrollernavigationdirectionforward animated:yes completion:nil];    } 

Comments

Popular posts from this blog

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

c# - Specify IP End Point in FiddlerCore -