开发者

Swipe a mapkit away from view

By default, when swipe a mapkit view, the map moves. This is great.

If I want to move away from the map view and load another viewcontroller's view, how do I accomplish that? I could add a button to do that, but I'd like to use gesture.

Thanks

THE FOLLOWING CODE WORKED:

(1) In the map view controller's header file, I added UIGestureRecognizerDelegate 开发者_JAVA技巧to support its protocol

(2) In map view controller's .m file , I added

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

(3) In map view controllers viewDidLoad method I added:

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

(4) This follow function is called for a left-swipe

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

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜