我在项目中使用GitHub https://github.com/Seitk/InfiniteScrollPicker/中的InfiniteScrollPicker。它现在的工作方式是当滚动菜单停止在选择上时它会自动加载故事板场景。我想更改它,以便您必须点击菜单图像才能加载故事板场景而不是在选择时发生。我该怎么办?
我认为这是InfiniteScrollPicker.m的相关代码,我需要更改。我想我会用某种手势识别器来做,但我不知道在下面的代码中将它添加到何处或如何添加。
// Disable scrolling when snapping to new location
dispatch_queue_t queue = dispatch_get_main_queue();
dispatch_async(queue, ^ {
[self setScrollEnabled:NO];
[self scrollRectToVisible:CGRectMake(newX, 0, self.frame.size.width, 1) animated:YES];
dispatch_async(dispatch_get_main_queue(), ^ {
SEL selector = @selector(infiniteScrollPicker:didSelectAtImage:);
if ([[self firstAvailableUIViewController] respondsToSelector:selector])
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[[self firstAvailableUIViewController] performSelector:selector withObject:self withObject:biggestView.image];
#pragma clang diagnostic pop
}
[self setScrollEnabled:YES];
snapping = 0;
});
这是我的ViewController.m
中相应代码的一部分- (void)infiniteScrollPicker:(InfiniteScrollPicker *)infiniteScrollPicker didSelectAtImage:(UIImage *)buttonIndex
{
if (buttonIndex == [UIImage imageNamed:@"menu_0.png"]) {
NSLog(@"First Menu Item Selected");
UIStoryboard *playGame = [UIStoryboard storyboardWithName:@"Storyboard_iPhone" bundle:nil];
UIViewController *playGameVC = [gameOver instantiateViewControllerWithIdentifier:@"PlayGame1"];
[self presentModalViewController:playGameVC animated:YES];
}
if (buttonIndex == [UIImage imageNamed:@"menu_1.png"]) {
NSLog(@"Second Menu Item Selected");
UIStoryboard *playGame = [UIStoryboard storyboardWithName:@"Storyboard_iPhone" bundle:nil];
UIViewController *playGameVC = [gameOver instantiateViewControllerWithIdentifier:@"GameOverScene"];
[self presentModalViewController:gameOverVC animated:YES];
感谢您的帮助!
答案 0 :(得分:0)
您应该查看UITapGestureRecognizer
,这是为了识别水龙头。以下是文档:https://developer.apple.com/library/ios/documentation/uikit/reference/UITapGestureRecognizer_Class/Reference/Reference.html