草庐IT

Delegate

全部标签

ios - 动画委托(delegate)未转换为 Swift 3.0

我想实现CABasicAnimation并在动画完成时通知UIViewController。来自这个资源:http://www.informit.com/articles/article.aspx?p=1168314&seqNum=2我知道我可以将viewcontroller指定为动画的委托(delegate)并覆盖viewcontroller中的animationDidStop方法。但是,当我将以下代码行转换为Swift时:[animationsetDelegate:self];像这样:animation.delegate=self//没有setDelegate方法XCode提示:C

ios - SWIFT iOS 中未调用委托(delegate)

我创建了2个View,一个是使用协议(protocol)和委托(delegate)。对于第一个View,未调用委托(delegate)函数。我的FirstViewController:我在这里访问委托(delegate)函数。importUIKitclassNextViewController:UIViewController,DurationSelectDelegate{//varsecondController:DurationDel?varsecondController:DurationDel=DurationDel()@IBActionfuncNext(sender:AnyO

uitextfield - UIAlertController 的文本字段委托(delegate)未被调用

我已将UITextField添加到UIAlertController,但shouldChangeCharactersInRange不会被触发。为什么?我设置委托(delegate)。letalertController=UIAlertController(title:"",message:"xxx",preferredStyle:.Alert)self.presentViewController(alertController,animated:true,completion:nil)lettextField=UITextField()textField.delegate=selfal

swift - 错误 : 'Delegate must respond to locationManager:didUpdateLocations:' when collecting user location

所以我想在用户点击按钮时收集用户位置,并稍后在我的应用程序中使用该位置。在我当前的实现中,当点击按钮时,应该提示用户允许共享位置,然后他们应该登录到应用程序(如果你想知道的话,通过Firebase匿名登录),并且应该打印用户位置信息到控制台。提示有效,但是在点击允许位置按钮后,我的应用程序终止duetouncaughtexception'NSInternalInconsistencyException'原因是'DelegatemustrespondtolocationManager:didUpdateLocations:'这很奇怪,因为我的代码中确实有一个didUpdateLocati

ios - 从 Objective-C 文件中的 AppDelegate.swift 访问 UIWindow

我正在开发swift项目,我需要使用我的旧Objective-C代码。我确实设法创建了-Bridge-Header.h文件,它对我有用。现在在我的Objective-C代码中,我需要从AppDelegate.swift引用UIWindow,有没有人以前做过这个?请指导我! 最佳答案 首先要访问ObjC中的Swift类,您可以导入编译器生成的头文件以将这些文件公开给ObjC。它会像ProductModuleName-Swift.h。(这个文件并不真正存在,但Xcode会自动为你创建它)#import"YourProductName-S

ios - WatchKit 并发症 : get Complication data from extension delegate

我的WatchKit扩展中有我需要的所有数据(从iOS应用程序传递)。我使用WatchKitInterfaceController中的数据填充了一个表格,效果很好。我正在尝试找出最佳方法来在我的WatchKitComplicationController中获取相同的数据。目前,在InterfaceController中,使用didReceiveUserInfo传入数据:funcsession(session:WCSession,didReceiveUserInfouserInfo:[String:AnyObject]){ifletbeachValue=userInfo["Surf"]a

在 uiview 中具有超过 1 个 uitextfield 的 iOS 快速委托(delegate)

我有一个iOS应用程序,有一个UIView和三个UITextField(超过1个)我想了解我的类ViewController管理UITextField的最佳做法是什么。-类MainViewController:UIViewController,UITextFieldDelegate?我想知道,因为我有多个UITextField而只有一个functextField(textField:UITextField,shouldChangeCharactersInRangerange:NSRange,replacementStringstring:String)->Bool

具有 mkmapview 和 uitextfield 委托(delegate)函数的 Swiftui

我正在练习和阅读有关SwiftUI的内容,我开始制作一个简单的应用程序,您可以在其中将位置输入到TextFieldViewfromswiftUI然后再次在SwiftUI中输入mkmapview将转到我搜索的那个位置。我似乎一辈子都无法掌握如何使用我的mkmapview设置此功能。此外,如果不进行导航、呈现新View或删除View,我什至无法找到从Textfield关闭键盘的方法。谁能告诉我如何关闭键盘?我习惯于resignFirstResponder()或didFinishEditing()。此外,是否有人对如何从swiftUI向MKMapView分配功能有任何建议,还是我看错了?我想

ios - 从多个 View Controller 接收委托(delegate)方法调用

我有一个带有SplitViewController的应用程序。MasterViewController是一个UITableViewController。DetailViewController是一个带有MapView的UIViewController。我正在调用一个API来获取事件列表。在tableView中,我想显示事件的名称和地址。在mapView中,我想标记这些事件的位置。我有一个名为DataLoader的类,我在其中调用API、解析JSON对象并创建Event对象并将它们成功放入数组中。importFoundationimportSwiftyJSON@objcprotocolD

ios - 当广告加载失败时在 Swift 中隐藏 iAd ADBannerView - 没有委托(delegate)或委托(delegate)没有实现 didFailToReceiveAdWithError

这是我使用的代码:varbannerView=ADBannerView()self.canDisplayBannerAds=true//showadbannerifanadloadsfuncbannerViewDidLoadAd(banner:ADBannerView!){bannerView.hidden=false}//hideadbanneriftheadfailstoloadfuncbannerViewFailsToLoadAd(banner:ADBannerView!,didFailToReceiveAdWithErrorerror:NSError!){bannerView.