【发布时间】:2014-11-29 10:10:27
【问题描述】:
我在 StoryBoard 的 UIViewController 上设置了以下平移手势代码。
在 ViewDidLoad 中:
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
[self.view addGestureRecognizer:panRecognizer];
然后我有以下调用:
#pragma mark - GESTURE RECOGNIZERS
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{
CGPoint velocity = [panRecognizer velocityInView:self.view];
NSLog(@"Pan Detected.");
if(velocity.x > 0)
{
NSLog(@"Pan went right.");
}
else
{
NSLog(@"Pan went left.");
if (panRecognizer.state == UIGestureRecognizerStateChanged)
NSLog(@"State Changed.");
}
}
当我从左向右拖动手指时,上面的代码会触发。我希望它仅在我从屏幕右边缘拖动时触发。然后我想继续使用另一个 StoryBoard 上的 UIViewController。 (我想从右边缘模态地将设置屏幕拖到应用程序的主屏幕上)。 UIViewController 的设置只需要部分拖到屏幕上。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"prepareForSegue: %@", segue.identifier);
if([segue.identifier isEqualToString:@"Settings"])
{
NSLog(@"Show Settings View Controller");
OLStoryboardLink *storyboardLink = segue.destinationViewController;
//send the string
storyboardLink.setStoryboardName = @"Settings";
storyboardLink.transitioningDelegate = self;
[self presentViewController:storyboardLink animated:YES completion:nil];
}
}
如何从屏幕右边缘触发平移手势的 segue?
【问题讨论】:
标签: ios uiviewcontroller uistoryboardsegue uipangesturerecognizer