Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8204867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:01:52+00:00 2026-06-07T08:01:52+00:00

I’ve got a QuickLook view that I view some of my app’s documents in.

  • 0

I’ve got a QuickLook view that I view some of my app’s documents in. It works fine, but I’m having my share of trouble closing the view again. How do I create a touch event / gesture recognizer for which I can detect when the user wants to close the view?

I tried the following, but no events seem to trigger when I test it.

/------------------------ [ TouchPreviewController.h ]---------------------------
#import <Quicklook/Quicklook.h>

@interface TouchPreviewController : QLPreviewController

@end

//------------------------ [ TouchPreviewController.m ]---------------------------
#import "TouchPreviewController.h"

@implementation TouchPreviewController

- (id)init:(CGRect)aRect {
    if (self = [super init]) {
        // We set it here directly for convenience
        // As by default for a UIImageView it is set to NO
        UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc]
                                                initWithTarget:self action:@selector(handleSingleDoubleTap:)];
        singleFingerDTap.numberOfTapsRequired = 2;
        [self.view addGestureRecognizer:singleFingerDTap];
        [self.view setUserInteractionEnabled:YES];
        [self.view setMultipleTouchEnabled:YES];
        //[singleFingerDTap release];
    }
    return self;
}

- (IBAction)handleSingleDoubleTap:(UIGestureRecognizer *) sender {
    CGPoint tapPoint = [sender locationInView:sender.view.superview];
    [UIView beginAnimations:nil context:NULL];
    sender.view.center = tapPoint;
    [UIView commitAnimations];

    NSLog(@"TouchPreviewController tap!" ) ;
}

// I also tried adding this
- (BOOL)gestureRecognizer:(UIGestureRecognizer *) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*) otherGestureRecognizer {
    return YES;
}

@end

Edit: For clarification, this is how I instantiate the controller:

documents = [[NSArray alloc] initWithObjects: filename , nil ] ;

preview = [[TouchPreviewController alloc] init];
preview.dataSource = self;
preview.delegate = self;

//set the frame from the parent view
CGFloat w= backgroundViewHolder.frame.size.width; 
CGFloat h= backgroundViewHolder.frame.size.height;
preview.view.frame = CGRectMake(0, 0,w, h);

//refresh the preview controller
[preview reloadData];
[[preview view] setNeedsLayout];
[[preview view] setNeedsDisplay];
[preview refreshCurrentPreviewItem];

//add it  
[quickLookView addSubview:preview.view];

Also, I’ve defined the callback methods as this:

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller
{
    return [documents count];
}

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index
{
    return [NSURL fileURLWithPath:[documents objectAtIndex:index]];
}

Edit2: One thing i noticed. If I try making swiping gestures, I get the following message. This could shed some light on what is wrong/missing?

Ignoring call to [UIPanGestureRecognizer setTranslation:inView:] since
gesture recognizer is not active.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:01:54+00:00Added an answer on June 7, 2026 at 8:01 am

    I think your example code is incomplete. It isn’t clear how you are instantiating the TouchPreviewController (storyboard, nib file or loadView.)

    I have never used the class so I could be way out in left field.

    If you’ve already instantiated a UITapGestureRecognizer in the parent viewController, it is absorbing the tap events and they aren’t passed on to your TouchPreviewController.

    I would implement the view hierarchy differently by attaching the UITapGestureRecognizer to the parent viewController and handle presentation and unloading of the QLPreviewController there.

    I think you might not have to subclass QLPreviewController by instantiating the viewController from a nib file.

    When your parent viewController’s UITapGestureRecognizer got an event you would either push the QLPreviewController on the navigation stack or pop it off the navigation stack when done.

    Hope this is of some help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.