【发布时间】:2014-02-24 15:11:17
【问题描述】:
我在我的项目中使用来自 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];
感谢您的帮助!
【问题讨论】:
标签: ios uiviewcontroller uiscrollview uistoryboard