草庐IT

make_member_delegate

全部标签

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)方法中加载此方

C++ 的 make_unique(含 C++ 代码示例)

std::make_unique是C++11标准引入的一个模板函数,用于动态分配指定类型的内存,并返回一个指向分配内存的唯一指针(即std::unique_ptr)。std::make_unique的语法如下:templatetypenameT,typename...Args>std::unique_ptrT>make_unique(Args&&...args);其中,T是指定的类型,Args是可变长模板参数包,用于传递给指定类型的构造函数的参数。在调用std::make_unique时,通过Args包传入构造函数的参数会被转发给类型T的构造函数,以生成相应的对象实例。该函数返回的指针是一个s

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

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