从视图中滑动mapkit

时间:2011-10-04 11:14:59

标签: ios-4.2

默认情况下,在滑动mapkit视图时,地图会移动。这很棒。

如果我想离开地图视图并加载另一个viewcontroller的视图,我该如何实现?我可以添加一个按钮来执行此操作,但我想使用手势。

由于

以下代码工作:

(1)在地图视图控制器的头文件中,我添加了UIGestureRecognizerDelegate以支持其协议

(2)在地图视图控制器的.m文件中,我添加了

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer 
   shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

(3)在地图视图控制器中我添加了viewDidLoad方法:

UISwipeGestureRecognizer *leftSwipe = 
[[[UISwipeGestureRecognizer alloc] 
  initWithTarget:self action:@selector(leftSwipeReceiver:)] autorelease];
leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
leftSwipe.delegate = self;
[self.view addGestureRecognizer:leftSwipe];

(4)调用左键滑动

- (void)leftSwipeReceiver:(UIGestureRecognizer *)recognizer
{
    NSLog(@"leftSwipeReceiver:");

}

0 个答案:

没有答案