ios - How do I add a Touch Event to this UIScrollView Infinite Scroll Picker? -
i'm using infinitescrollpicker github https://github.com/seitk/infinitescrollpicker/ in project. way works right when scroll menu stops on selection automatically loads storyboard scene. want change have tap on menu image in order load storyboard scene instead of happening on selection. how that?
i think relevant code infinitescrollpicker.m need change. i'm thinking sort of gesture recognizer i'm not sure or how add code below.
// disable scrolling when snapping 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; });
this part of corresponding code 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];
thanks help!
you should uitapgesturerecognizer
, meant recognize taps. here documentation: https://developer.apple.com/library/ios/documentation/uikit/reference/uitapgesturerecognizer_class/reference/reference.html
Comments
Post a Comment