ios - top bar in UIPageViewController -
i based application default "page-based app" in xcode. i'm trying display navigation bar on top of dataviewcontroller in storyboard without using navigation controller. problem is, when swipe left , right, navigation bar seems go along gesture. how can make "not-movable"?
things tried:
- putting navigation bar in rootviewcontroller instead. when simulate app, navigation bar not visible.
edit: rootviewcontroller.m
- (void)viewdidload{ [super viewdidload]; // additional setup after loading view, typically nib. // configure page view controller , add child view controller. self.pageviewcontroller = [[uipageviewcontroller alloc] initwithtransitionstyle:uipageviewcontrollertransitionstylepagecurl navigationorientation:uipageviewcontrollernavigationorientationhorizontal options:nil]; self.pageviewcontroller.delegate = self; gjdataviewcontroller *startingviewcontroller = [self.modelcontroller viewcontrolleratindex:0 storyboard:self.storyboard]; nsarray *viewcontrollers = @[startingviewcontroller]; [self.pageviewcontroller setviewcontrollers:viewcontrollers direction:uipageviewcontrollernavigationdirectionforward animated:no completion:null]; self.pageviewcontroller.datasource = self.modelcontroller; [self addchildviewcontroller:self.pageviewcontroller]; [self.view addsubview:self.pageviewcontroller.view]; // set page view controller's bounds using inset rect self's view visible around edges of pages. cgrect pageviewrect = self.view.bounds; if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiompad) { pageviewrect = cgrectinset(pageviewrect, 40.0, 40.0); } self.pageviewcontroller.view.frame = pageviewrect; [self.pageviewcontroller didmovetoparentviewcontroller:self]; // add page view controller's gesture recognizers book view controller's view gestures started more easily. self.view.gesturerecognizers = self.pageviewcontroller.gesturerecognizers; }
dataviewcontroller.m
- (void)viewwillappear:(bool)animated{ [super viewwillappear:animated]; self.datalabel.text = [self.dataobject description]; }
follow these steps:
- use 2nd trial: "putting navigation bar in rootviewcontroller instead." make navigation-bar immovable every age transition.
- now in rootviewcontroller.m, change line
cgrect pageviewrect = self.view.bounds;
cgrect pageviewrect = cgrectmake(self.view.bounds.origin.x, 64, self.view.bounds.size.width, self.view.bounds.size.height-64);
.where 64=20(status-bar height) + 44(navigation-bar) height.
2nd step adjust frame of dataviewcontroller's view below added navigation-bar in rootviewcontroller , navigation-bar not hide.
hope, helps you....happy coding! :-)
Comments
Post a Comment