기존 프로젝트 (https://github.com/ThornTechPublic/Onboarding-With-UIPageViewController-Final)를 사용하고 있습니다. 나는 또한 boutton으로 슬라이드를 수행하고 싶습니다. 내 단추 "다음"이 스 와이프와 동일한 기능을 수행하기를 원할 때 사용자가 탭하면 다음 화면으로 이동합니다. Button in blue. 그렇게하는 방법 ? 미리 감사드립니다.온보드 페이저에 boutton을 사용하십시오.
2
A
답변
1
다음은 내가하는 일입니다. 페이지에서 NSNotification을 사용하여 OnboardingPager가 버튼을 눌렀을 때 알 수있게하고 적절한 조치를 취합니다. 여기
는 예입니다 다음 StepZero 페이지에서, 나는이 OnboardingPager 클래스의 다음@IBAction func nextPressed(sender: UIButton) {
NSNotificationCenter.defaultCenter().postNotificationName("testbutton", object: nil)
}
다음, 나는이 첫 번째 페이지에서 이동 할 수있는 다음과 같은
override func viewDidLoad() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(nextPage(_:)), name: "testbutton", object: nil)
}
func nextPage(notification:NSNotification) {
self.setViewControllers([getStepOne()],
direction: UIPageViewControllerNavigationDirection.Forward,
animated: true,
completion: nil)
}
을 추가했다 (StepZero)에서 두 번째 (StepOne)로 이동하십시오.
+0
감사합니다 남자 : D –
이 질문을 중복으로 표시하도록 투표했습니다. http://stackoverflow.com/questions/7208871/is-it-possible-to-turn-page-programmatically-in-uipageviewcontroller –
동일한 문제가 아닙니다.) –