草庐IT

WithEvent

全部标签

ios 尝试左右拖动图像

我有一个游戏,在屏幕底部绘制了一排纸牌。我希望如此,如果用户触摸屏幕并将手向右移动,卡片将向右移动,直到他举起手。然后,如果他在触摸屏上向左移动手,卡片就会向左移动,直到他抬起手。我的第一个想法是使用滑动事件。但是在手指松开之前滑动不会给出消息,我希望卡片在手移动并触摸屏幕时移动。我的想法是获取触摸位置的x坐标,如果它比之前的x大,则将卡片向左移动,否则向右移动。我从这段代码开始,但有点卡在下一步该做什么上,或者我做错了-(void)touchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event{NSUIntegertouchCount=[t

ios - UIButton 句柄触摸然后通过?

是否可以处理UIButton发生的触摸,然后将其传递给下一个响应者? 最佳答案 编辑一个有效的方法也是覆盖UIResponder的touchesEnded:withEvent:方法-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event{//handletouch[supertouchesEnded:toucheswithEvent:event];}来自documentation:Thedefaultimplementationofthismethoddoesnothi

ios - 我可以打电话 - (void)touchesBegan :(NSSet *)touches withEvent:(UIEvent *)event on subview

我在我的View中识别触摸-如果某些情况发生我想用这个方法调用我的subview但它不起作用-(如果我不覆盖hittestWithEvent-这个View将被返回)我该怎么做?编辑:我想让原来的SUBVIEW得到“点击”,所以我尝试这样做:-(void)didTap:(MyTapGesture*)tap{//theoriginalviewthatwouldhavebeenreturnedbyhittest.couldbeanyarbitraryviewUIView*theView=[superhitTest:[taplocationInView:self]withEvent:nil];

ios - 为多点触控继承 UIControl 的 endTracking

我通过继承UIControl并覆盖以下方法来创建自定义控件*:-beginTrackingWithTouch:withEvent:-continueTrackingWithTouch:withEvent:-endTrackingWithTouch:withEvent:-cancelTrackingWithEvent:此控件将支持多点触控交互。具体来说,一个或两个手指可能会向下触摸,拖动一段时间,然后向上触摸,所有这些都是独立的。我的问题出现在这些多点触控事件的末尾,在endTrackingWithTouch:withEvent:中。系统在每个多点触摸序列中仅在我的控件上调用一次此方法,

ios - 在 UIButton 上滚动时滚动 UICollectionView

我有一个带有水平UICollectionView和两个UIButton的View(固定在右侧和左侧,屏幕宽度为25%)。我的需要是在我开始拖动按钮时滚动collectionView而不会松开按钮的点击手势。我试图覆盖我的按钮的touchesMoved并将触摸和事件发送到我的collectionView但它不起作用。-(void)touchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event{[supertouchesMoved:toucheswithEvent:event];if(self.delegate&&[self.delegatere

ios - shouldReceiveTouch 未调用

我在网上看到很多关于它的问题,尤其是在StackOverflow上。我测试了许多给定的答案,但就我而言,没有任何效果。我的类实现协议(protocol)UIGestureRecognizerDelegate:@interfaceCDMapViewController:CDViewController下面的方法是我类的@implentation中的xcode自动补全写的-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizershouldReceiveTouch:(UITouch*)touch{NSLog(@"notc

ios - 如何使用 hitTest :withEvent: to send touches from my nav bar to the underlying view under certain circumstances?

长话短说,如果我的UINavigationBar的alpha设置为0,我希望所有触摸都转到底层View(从带有导航栏的ViewController的角度来看,它只是是self.view)。如果是1.0,我希望它保留它们。我将UINavigationBar子类化,并试图覆盖hitTest:withEvent:,但我真的很困惑我在做什么,而且搜索也没什么帮助。我如何告诉它“如果alpha为0,将触摸发送到self.view,否则继续导航栏”? 最佳答案 您需要将View的引用发送到导航栏,将其设置为名为behindView或其他名称的属

iphone - 将触摸事件传递给 iOS 状态栏

我有一个UIWindow,其windowLevel设置为UIWindowLevelStatusBar+1。这个窗口有一个半透明的View,它阻挡了状态栏。有时我需要将触摸事件从View传递到状态栏。有什么想法吗? 最佳答案 因此,似乎可以使用UIWindow的自定义子类覆盖hitTest:withEvent:,手动检测subview中的触摸,并始终返回nil。-(UIView*)hitTest:(CGPoint)pointwithEvent:(UIEvent*)event{if([eventtype]==UIEventTypeTou

objective-c - 自定义 UIControl 始终发送 nil UIEvent 对象

我有一个派生自UIControl的类,我在其中监视touchesBegan/Moved/Ended/Cancelled事件。在这些事件中,我对super响应者和下一个响应者调用相同的事件,如下所示:[self.nextRespondertouchesEnded:toucheswithEvent:event];[selfsendActionsForControlEvents:UIControlEventTouchUpInside];[supertouchesEnded:toucheswithEvent:event];我有一个拥有TableView的父控件。TableView中的每个单元格

objective-c - 如何阻止 UIScrollView 从其父 View 获取触摸事件?

我有一个包含UIScrollView的UIView。此UIView应该响应某些触摸事件,但由于它包含scrollView而没有响应。此scrollView的contentView设置为OuterView内的MoviePlayer。现在,每当我点击MoviePlayer所在的区域时,我的OuterView的触摸事件都没有响应。我什至将电影播放器​​的userInteraction设置为NO。但现在看来scrollView正在干扰。我已经在SO本身上引用了这篇文章。Howcanasuperviewintereceptatouchsequencebeforeanyofitssubviews?