草庐IT

event-driven

全部标签

ios - UIWindow 子类 : Touches event not get fired

我想在当前项目中实现session时间功能。因此,为此我尝试子类化UIWindow并覆盖touchesBegan和touchesEnded方法。classBaseWindow:UIWindow{convenienceinit(){self.init(frame:UIScreen.mainScreen().bounds)}privatevarsessionTimeOutTimer:NSTimer?overridefunctouchesBegan(touches:Set,withEventevent:UIEvent?){sessionTimeOutTimer?.invalidate()}o

swift - swift 中 "event listeners"的想法如何分为 Action 和协议(protocol)?

我的问题作为一名正在学习Swift的新程序员。我想知道为什么在事件监听器的实现方式之间似乎存在任意划分。在一些教程中,指出您可以简单地在Storyboard上的View元素和ViewController之间拖动以创建Action(事件监听器)。@IBActionfuncclickButtonListener(_sender:UIButton){print("helloworld")}但在后面的教程中,我注意到某些类似事件监听器的功能也以协议(protocol)的形式实现classViewController:UIViewController,UIScrollViewDelegate{f

ios - CoreLocation 线程崩溃崩溃 : com. apple.CoreLocation.ConnectionClient.0x16fcb870.events

我在我们的生产应用程序中遇到了Apple的CoreLocation线程崩溃。我无法在我的测试中重现它,也很难弄清楚它是在CoreLocation内部。目前它只发生在少数人口中,但我可以看到它正在变得越来越大。Crashed:com.apple.CoreLocation.ConnectionClient.0x16fcb870.events0CoreLocation0x2aa2db54CLClientCreateIso6709Notation+536751CoreLocation0x2aa2dc7bCLClientCreateIso6709Notation+539702CoreLocati

ios - event.touchesForView().AnyObject() 在 Xcode 6.3 中不起作用

这在之前非常有效:funcdoSomethingOnDrag(sender:UIButton,event:UIEvent){lettouch=event.touchesForView(sender).AnyObject()asUITouchletlocation=touch.locationInView(sender)}但是在Xcode6.3中,我现在得到错误:Cannotinvoke'AnyObject'withnoarguments我该如何解决这个问题? 最佳答案 在1.2中,touchesForView现在返回原生SwiftS

swift 3 : how can I detect the touch event on UIScrollView?

我使用下面的函数来检测ScrollView上的触摸事件。overridefunctouchesBegan(_touches:Set,withevent:UIEvent?)但这无法检测到任何触摸事件。如何检测ScrollView上的触摸事件? 最佳答案 在您的scrollView上设置一个点击识别器:在您的viewDidLoad中添加以下内容:letscrollViewTap=UITapGestureRecognizer(target:self,action:#selector(scrollViewTapped))scrollView

macos - 检查 keyDown event.modifierFlags 产生错误

我继承了NSTextView并重写了keyDown。我想检测命令键组合。例如,Command-L。Apple'sdocumentation表示您只是使用NSEventModifierFlags.CommandKeyMask和修饰符标志(在传递的NSEvent中)。当我这样做时:letck=NSEventModifierFlags.CommandKeyMask我收到一个奇怪的错误:Binaryoperator'&'cannotbeappliedtotwo'NSEventModifierFlags'operands.这是怎么回事?这是swift2.0,xcode7。谢谢!

iOS : UIView with subview Button click event not firing when zPosition of view changes

我在我的应用程序中使用父ViewController和subviewController。其中父ViewController包含subview作为zPosition值为2的按钮。现在,我将subviewController添加到父ViewController,如下所示,funcaddChildViewController(){letstoryboard=UIStoryboard(name:"myStoryBoard",bundle:nil)letchildVC=storyboard.instantiateViewController(withIdentifier:"childVC")a

安卓 : How to set onClick event for Button in List item of ListView

我想为Listview项中使用的按钮添加onClick事件。如何为列表项中的按钮提供onClick事件。 最佳答案 在适配器类中publicViewgetView(finalintposition,ViewconvertView,ViewGroupparent){LayoutInflaterinflater=getLayoutInflater();Viewrow=inflater.inflate(R.layout.vehicals_details_row,parent,false);ButtondeleteImageView=(Bu

安卓 : How to set onClick event for Button in List item of ListView

我想为Listview项中使用的按钮添加onClick事件。如何为列表项中的按钮提供onClick事件。 最佳答案 在适配器类中publicViewgetView(finalintposition,ViewconvertView,ViewGroupparent){LayoutInflaterinflater=getLayoutInflater();Viewrow=inflater.inflate(R.layout.vehicals_details_row,parent,false);ButtondeleteImageView=(Bu

Java2D : interaction between XWindows events and frame rate

我在Linux/XWindows上的简单Java2D应用程序中遇到系统事件和窗口刷新率之间的意外交互。下面的小示例可以很好地证明这一点。这个程序创建了一个小窗口,其中半圆以不同的旋转度显示。图形以每秒60帧的速度更新,以产生闪烁的显示。这是通过BufferStrategy实现的,即调用其show方法。但是,我注意到当我(a)将鼠标移到窗口上以便窗口接收鼠标悬停事件或(b)按住键盘上的某个键以便窗口接收键盘事件时,闪烁会增加可见。因为调用BufferStrategy.show()的速率不受这些事件的影响,从控制台上的打印输出可以看出(它们应该始终保持在60fps左右).但是,更快的闪烁表