Dường như nút này không bị ép.Làm thế nào một UIViewController bên trong một UIPageController có được các sự kiện cảm ứng?
tôi đã cố gắng:
UIPageViewController Gesture recognizers
Tuy nhiên, đây là bắt
nếu chuyển trang UIPageViewController là UIPageViewControllerTransitionStyleScroll sau đó
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
NSLog(@"%@",self.pageViewController.gestureRecognizers.description);
NSLog(@"%@",self.pageViewController.gestureRecognizers.description);
sẽ chỉ đơn giản là được sản phẩm nào.
Tôi đã thử thêm gestureRecoqnizers của riêng mình thay vì nút vào chế độ xem phụ của UIViewControllers. Nó vẫn không hoạt động.
Vì vậy, tôi có UIPageViewController hiển thị UIViewController có chế độ xem có một số nút. Làm cách nào để tôi nhấn nút đó?
Tôi cũng đã cố gắng cả hai giải pháp ở đây:
http://emlyn.net/posts/stopping-gesture-recognizers-in-their-tracks
Không hoạt động. Trước hết, tôi không thể vô hiệu hóa recoqnizers cử chỉ của UIPageViewController vì không có điều đó. Trong chế độ scrollView, UIPageViewController không có recoqnizers cử chỉ.
Tôi đã cố gắng thêm các công cụ recoqnizers cử chỉ của riêng mình vào nút của riêng tôi nhưng không bao giờ được gọi.
Tôi muốn UIPageViewController vẫn xử lý thao tác vuốt. Nhưng không khai thác.
Tôi không thể truy cập vào các trình khôi phục cử chỉ của UIPageViewControllers vì self.pageViewController.gestureRecognizers trống. UIPageViewController dường như chỉ "hấp thụ" tất cả các sự kiện nhấn. Vì vậy, nút của tôi không nhận được nó.
Tôi có thể thêm nút ở phía trước UIPageViewController nhưng nút đó sẽ hấp thụ tác vụ vuốt mà tôi muốn UIPageVIewController vẫn xử lý.
Bằng cách nếu chúng ta sử dụng các mẫu từ IOS (Tạo một ứng dụng trang dựa, và thay đổi quá trình chuyển đổi để di chuyển các pageviewcontroller.gesturerecoqnizers sẽ trống
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Configure the page view controller and add it as a child view controller.
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];//Turn this to scroll view
self.pageViewController.delegate = self;
SDDataViewController *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 the page view controller's bounds using an inset rect so that self's view is visible around the edges of the 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 the page view controller's gesture recognizers to the book view controller's view so that the gestures are started more easily.
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
NSLog(@"%@",self.pageViewController.gestureRecognizers.description); //This is empty
while (false);
}
Có nút có một mục tiêu và hành động? – Wain
tất nhiên. Tôi đã nói thẳng. Nó hoạt động tốt nếu không phải bên trong UIPageViewController. –
Vậy tại sao trình nhận dạng cử chỉ? Và bạn đã thiết lập bộ điều khiển của bạn là đại biểu và kiểm tra các phương thức đại biểu đã được gọi? – Wain