是否有可能实现一种解决方案,允许用户在屏幕上以某种方式滑动,然后触发某种事件以加载另一个UIView用于例如Wikipedia app
我的问题是我希望它超过我的MKMapView - 但我猜它会干扰地图。
有没有人有简单的代码段?
答案 0 :(得分:2)
您应该可以使用UIGestureRecognizers
执行此操作答案 1 :(得分:2)
正如nduplessis所说,UIGestureRecognizer会做到这一点。它应该能够区分拖动地图和执行滑动手势,所以你应该没问题。
创建和添加手势识别器:
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[mapView addGestureRecognizer:swipeRight];
对手势做出反应:
- (void)swipeRightAction:(UISwipeGestureRecognizer *)gestureRecognizer
{
//Switch views...(do this however you have been switching views)
[mapView.superview addSubview:wikipediaView];
[mapView removeFromSuperview];
}