ios - Using UIPageViewController to sign-up user -
i working on user sign-up part of ios app , trying use page views user input. so, first page view takes user's first name, next 1 takes takes last name, phone number. user receives verification code put in user in next page view. when verification code correct user allowed go (swipe right) next page view.
the problem facing unable trap user input in properties of view controller derives uipageviewcontroller.
i using :
- (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerafterviewcontroller:(uiviewcontroller *)viewcontroller { nsuinteger index = [(signupchildviewcontroller *)viewcontroller index]; signupchildviewcontroller *current=(signupchildviewcontroller *)viewcontroller; nslog(@"%@", current.usercredentials.text); if(index==3) { firstpass=yes; if([verificationcodeuser isequaltostring:verificationcode]) { verificationpassed=yes; index++; } else { uialertview *alert=[[uialertview alloc] initwithtitle:@"oh snap!" message:@"you haven't entered correct verification code." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; return [self viewcontrolleratindex:index]; } } if(index==3) { firstpass=yes; } index++; if (index == 6) { return nil; } [self updateinfo:index]; return [self viewcontrolleratindex:index]; }
the updateinfo method looks this:
(void)updateinfo:(nsinteger)ind { switch ([ind integervalue]) { case 0: firstname=textview.text; break; case 1: lastname=textview.text; break; case 2: phonenumber=textview.text; break; case 3: verificationcodeuser=textview.text; break; case 4: birthday=textview.text; break; case 5: password=textview.text; break; } }
here based on index of page, appropriate property set. problem property getting set correctly, @ times gets empty string in textview though user has entered string. how capture user input while using pageviews?
viewcontrollerafterviewcontroller:
bad place call updateinfo:
because you're assuming you've transitioned index when may not case. viewcontrollerafterviewcontroller:
can called during cases other successful transition.
instead, try updating info during uipageviewcontrollerdelegate
methods pageviewcontroller:didfinishanimating:previousviewcontrollers:transitioncompleted:
or pageviewcontroller:willtransitiontoviewcontrollers:
know sure view has transitioned or transition.
Comments
Post a Comment