本文介绍了QLPreviewController的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想去QLPreviewController.view。事实上,我想在其视图中捕捉一个点击事件来显示/隐藏工具栏等。我正在尝试:

I just trying to get to QLPreviewController.view. Indeed, I want to catch a tap event on its view to show/hide toolbar etc. I am trying:

QLPreviewController* qlpc = [QLPreviewController new];
    qlpc.delegate = self;
    qlpc.dataSource = self;
    qlpc.currentPreviewItemIndex=qlIndex;
    [navigator pushViewController:qlpc animated:YES];
    qlpc.title = [path lastPathComponent];
    [qlpc setToolbarItems:[NSArray arrayWithObjects:self.dirBrowserButton,self.space, self.editButton, self.btnSend, nil] animated:YES];
    UITapGestureRecognizer* gestTap  = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)];
    gestTap.cancelsTouchesInView=NO;
    [qlpc.view addGestureRecognizer:[gestTap autorelease]];
    [qlpc release];

没有任何反应

如果我附上UITapRecognizer到navigationController.view上,只有当我触摸工具栏/导航栏时它才会触发。在这种情况下,UISwipeGestureRecognizer工作正常。

If I attach UITapRecognizer onto navigationController.view, it fires only if I touch toolbar/navbar. UISwipeGestureRecognizer works fine in that case.

我试图附加透明覆盖视图并在其上添加手势识别器,但没有运气。
嗯,我看到一些应用程序实现了这样的功能,所以很明显它是可能的,但是怎么样?
对不起,我一整天用谷歌搜索,没有找到任何解决方案。请帮帮我。

I tried to attach a transparent overlay view and add gesture recognizers on it, but no luck.Well, I saw some apps that implements such a feature so obviously it is possible, but how?Sorry, I googled all day long and didn't find any solution. Please, help me.

推荐答案

我发现这里没有任何答案可行,但为我做的那个是继承QLPreviewController并覆盖viewDidAppear为所以:

I found none of the answers here to work, but the one that did for me was to subclass QLPreviewController and override viewDidAppear as so:

- (void)viewDidAppear:(BOOL)animated
{ 
    UITapGestureRecognizer *gestTap  = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)];
    gestTap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:[gestTap autorelease]];
}

这篇关于QLPreviewController的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:56