开发者

How do I display a pop-up menu when a user touches content within a Quartz-drawn PDF?

开发者 https://www.devze.com 2023-03-28 15:13 出处:网络
I created an iPhone PDF viewer using Quartz that also has a page-flip animation.This works well, but now I\'d like to add some more interactive functionality.

I created an iPhone PDF viewer using Quartz that also has a page-flip animation. This works well, but now I'd like to add some more interactive functionality.

In particular, I'd like to add the ability to pop up a menu when the user touches some part of the PDF content. How can I make my PDF display respond to touch events over certain parts of the displayed PDF material开发者_C百科?


It's pretty easy. Just add a UIGestureRecognizer to your scrollview. You may wanna make some calculations to get the correct touch point relative to the pdf. I've written an pdf iOS framework that does exactly that, you may wanna check it out. There I create the tap recognizers in the ScrollView's init method:

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapped:)];
    singleTap.numberOfTapsRequired = 1;
    [singleTap requireGestureRecognizerToFail:doubleTap];
    [self addGestureRecognizer:singleTap];
    [singleTap release];

(Note that I added here the "requireGestureRecognizerToFail:doubleTap" because I also respond to double and tripple taps for zomming)

0

精彩评论

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

关注公众号