草庐IT

event-driven-design

全部标签

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

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

ios - 核心数据 : error: Failed to call designated initializer on NSManagedObject class

我做了一些研究,我真的不明白这里发生了什么。当我在TableView中选择一行时出现此错误:Wish[1392:37721]CoreData:错误:无法调用NSManagedObject类“Wish.ProduitEntity”上的指定初始值设定项(lldb)错误出在ViewController类中的prepareForSegue方法上。感谢帮助importUIKitimportCoreDataclassViewController:UIViewController,UITableViewDataSource,UITableViewDelegate{@IBOutletweakvarle

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

ios - IB Designables 无法更新自动布局状态

每当我将一个类设置为@IBDesignable时,我都会收到以下错误并且它不会预渲染View。我尝试按照类似帖子中的建议更改我的运行路径搜索路径设置,但没有效果。问题是我不知道错误的性质,Xcode也没有帮助。干杯。 最佳答案 从您的代码中删除“IB_DESIGNABLE”(Objective-C),并且只对xib使用“IBInspectable”,然后它就可以正常工作了。或者只是等待xcode的更新。 关于ios-IBDesignables无法更新自动布局状态,我们在StackOver

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

java - 膨胀类 android.support.design.widget.CoordinatorLayoute 时出错

我正在尝试运行我的应用程序,但我不断收到标题中列出的错误。我已经阅读过,有人说尝试将主题更改为AppCombat主题,但这似乎不起作用。这是我遇到的错误:Process:com.example.jmeyer27.crazytiles,PID:3924java.lang.RuntimeException:UnabletostartactivityComponentInfo{com.example.jmeyer27.crazytiles/com.example.jmeyer27.crazytiles.GameActivity}:android.view.InflateException:B

安卓 : 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