How do I display a pop-up menu when a user touches content within a Quartz-drawn PDF?
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)
精彩评论