草庐IT

anonymous-delegates

全部标签

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

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

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.

swift - iOS 9 中的 requestLocation() 多次调用 didUpdateLocation 委托(delegate)

所以在iOS9上有了新的requestLocation()方法。我试图用它来只获取一个位置更新,但它多次点击didUpdateLocations。这不是应该只调用一次吗?我已将distanceFilter设置为1000.0,因此范围很广,有助于快速返回。有任何想法吗?即使我在委托(delegate)方法中调用stopUpdatingLocation(),我仍然会得到三次委托(delegate)。注意:当我改用StartUpdatingLocation时会发生相同的行为,我只想返回一次,因为我想获得用户的当前国家/地区,因此将位置提供给reversegeocoder提前致谢代码如下:fu

swift - 为什么 "var delegate: UIApplicationDelegate?"在 UIApplication 中成为可选项?那会是 fatal error 吗?

如果delegate属性曾经是nil,应用将处于不可恢复的状态。classUIApplicationDeclarationunowned(unsafe)vardelegate:UIApplicationDelegate?DiscussionEveryappmusthaveanappdelegateobjecttorespondtoapp-relatedmessages.Forexample,theappnotifiesitsdelegatewhentheappfinisheslaunchingandwhenitsforegroundorbackgroundexecutionstatus

ios - 弱委托(delegate)变为零

在我的应用程序中,我使用委托(delegate),这样我就可以在数据准备就绪时读取它。我正在调用来自两个类的委托(delegate)。这是我的代码protocolMyDelegate:class{funcgetData()}classMyDelegateCalss{weakvardelegate:MyDelegate?funcloadData(){//doingsomeactionsif(self.delegate!=nil){self.delegate!.getData!()}}}在一个类中,我在tableviewnumberOfSections委托(delegate)方法中加载此方

ios - 如何模态呈现 ViewController,然后在 ViewController 被关闭后运行回调函数/ block ,没有委托(delegate)?

我只是知道self.presentViewController(childVc,animated:true,completion:{})中的完成block在subviewController完成动画后被调用显示在屏幕上。实际上,我想运行一段代码,在subviewController的动画完成后显示关闭。我该怎么做,最好避免使用委托(delegate)来做到这一点?编辑:我从呈现的(子)ViewController中这样调用它:self.presentingViewController.dismissViewControllerAnimated(true){},但问题是subviewCo