草庐IT

UILongPressGestureRecognizer

全部标签

ios - UILongPressGestureRecognizer 按下坐标

我以这种方式在UIImageView上使用UILongPressGestureRecogniser:UILongPressGestureRecognizer*longPress=[[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPress:)];[ImageViewPhotoCardaddGestureRecognizer:longPress];-(void)longPress:(UILongPressGestureRecognizer*)gesture{if(gesture.stat

ios - 在 UILongPressgestureRecognizer 中间处理 App 进入后台

在我的应用程序中,我使用UILongPressgestureRecognizer将subview添加到UIGestureRecognizerStateBegan上的View,并在手势结束时删除该View。我的问题是,当应用程序在结束此手势(通过单击主页按钮或电源按钮锁定屏幕)之前进入后台时,当用户恢复应用程序(返回前台)时,我添加的subview仍然存在。请建议我一些方法来处理这个问题。我知道-(void)applicationDidEnterBackground:(UIApplication*)applicationdelegateinAppDelegate但我不知道如何使用这个委托

ios - UILongPressGestureRecognizer 是如何工作的

我正在尝试了解手势识别器的工作原理,并尝试让手势识别器告诉我长触摸何时开始以及何时结束,即使触摸没有移动也是如此。在viewDidLoad中,我添加了一个名为game的subview。在游戏中,我实现了两种识别触摸的方法。一个工作但不做我想做的事。另一个不起作用。Method1我刚刚添加了两个方法:-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{NSLog(@"Began");}-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event{NSLog(@

ios - 在 UILongPressGestureRecognizer 事件时增加 UIImageView

我想在用户触摸位置向我的View添加一个UIImageView,并在用户按住手指时让UIImageView增长。想象一个被吹大的气球。我希望UIImageView的中心在其增长时保持在用户的触摸位置。我认为最好的方法是UILongPressGestureRecognizer并写下了下面的内容。这确实按照我的计划工作,除了视觉效果有点起伏和笨拙。在UILongPressGestureRecognizer调用UIGestureRecognizerStateEnded之前,有什么方法可以使UIImageView的大小动画化?或者,是否有更好的方法来完全做到这一点?在.h中声明:CGPoint

iphone - UITapGestureRecognizer 识别为 UILongPressGestureRecognizer

我的CollectionView中的UITapGestureRecognizer有问题,我不知道错误。我想在有长按手势时做一个自定义Action,而当有点击手势时我什么都不做,所以我有这些方法:-(void)activateSelectionMode:(UILongPressGestureRecognizer*)gr{if(![self.collectionViewallowsSelection]){[self.collectionViewsetAllowsSelection:YES];NSLog(@"Seleccionactivada");}}-(void)pruebaTap:(UI

C# Xamarin - 将目标添加到 UILongPressGestureRecognizer,将其传递给在父 UIViewController 中实现的选择器

我在将事件从UICollectionViewCell提升到存在于父级UIViewController中的处理程序时遇到困难。我正在尝试在UICollectionViewCell上检测LongPress并在UIViewController中触发一个方法-将View置于“编辑模式”显示/隐藏UI元素并重新加载等。为此,我的UIViewController方法必须调用数据访问层,因此将方法放置在View层次结构中的这一层是有意义的。我遵循了来自Xamarin的官方文档和技术以及AdamKemp的重要建议here.在Xamarin.IOS中实现这一点有很多相互冲突的方法。las,目前,似乎没有

ios - 一定时间后取消 UILongPressGestureRecognizer

我在我的UICollectionView中使用了UILongPressGestureRecognizer。现在,当我在一定时间后(例如1秒)将手指放在CollectionView项目上时,我希望我的UILongPressGestureRecognizer结束并执行特定代码:if(gestureRecognizer.state==UIGestureRecognizerStateEnded){}这是我的代码:-(void)viewDidLoad{[superviewDidLoad];Public=[[PublicMethodsalloc]init];self.view.background

objective-c - UILongPressGestureRecognizer 不适用于 tableview

我在ViewDidLoad方法中将UILongPressGestureRecognizer添加到TableView。我添加这个是为了检测代码中TableView的长按。但它永远行不通。在ViewDidLoad中,我添加了这段代码:UILongPressGestureRecognizer*lpgr=[[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(handleLongPress:)];lpgr.minimumPressDuration=2.0;//secondslpgr.delegate=sel

iphone - 将 UILongPressGestureRecognizer 用于 UIScrollview 的 subview

在过去的四个小时里,我尝试了许多StackOverlow解决方案,但没有一个能帮助解决我的问题。在这里,我有一个UIScrollView在该ScrollView中有一个自定义UILabel和8个自定义UIImageView我想检测长按这样的东西可行UILongPressGestureRecognizer*longPress=[[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPressDidFire:)];longPress.minimumPressDuration=0.5;[scrol

ios - 即使未实现,uilongpressgesturerecognizer 也会崩溃

我尝试了所有可能的搜索,但在一个星期内没有找到任何类似的东西。我正在制作一个显示表格View的应用程序。可以使用Cell类中的UIPanGestureRecognizer拖动单元格(由自定义类和InterfaceBuilder制作)。一切正常,除了当我将手指按住单元格时,应用程序因错误而崩溃:-[UILongPressGestureRecognizertranslationInView:]:unrecognizedselectorsenttoinstance0x94670a0***Terminatingappduetouncaughtexception'NSInvalidArgumen