草庐IT

delegating

全部标签

ios - Swift - 调用自定义委托(delegate)方法

我正在使用BMPlayer库并希望实现自定义控件,为此我有以下类确认以下协议(protocol)@objcpublicprotocolBMPlayerControlViewDelegate:class{funccontrolView(controlView:BMPlayerControlView,didChooseDefitionindex:Int)funccontrolView(controlView:BMPlayerControlView,didPressButtonbutton:UIButton)funccontrolView(controlView:BMPlayerContro

ios - 在 Swift 中使用委托(delegate)模式重构 CNContactPicker UI 代码

我已经在ViewController中成功实现了iOS10中iOS提供的CNContactPickerViewControllerContactsUI,因此我可以让用户选择多个联系人来邀请参加一个事件。我试图通过实现委托(delegate)模式来减小这个单一ViewController的大小,但我卡在了黑屏上。我查看了一些资源,并认为我正在调用委托(delegate)并相应地定义协议(protocol)。我有一个ViewControllerCreateEventViewController,它实现了我自定义的ContactsToInviteDelegate。该协议(protocol)如

ios - UITableViewCell 委托(delegate) indexPath

今天真好,我是iOS开发的新手。我正在开发项目,其中有tableViewCell和按钮,progressBar。当我点击这个单元格的按钮indexPath通过委托(delegate)传递给viewController然后用另一种方法我是下载一些数据并在progressBar中显示它的进度。因此,当我点击一个单元格然后点击另一个单元格时,第一个单元格的进度停止并在第二个单元格继续,有人可以帮忙吗?提前致谢)这是viewController中的委托(delegate)方法:funcdidTouchButtonAt(_indexPath:IndexPath){songs[indexPath.

ios - 当前台应用程序发生内存不足崩溃时,调用 App Delegate 生命周期的哪一部分?

尝试调试用户遇到的崩溃,但并未显示在我们的崩溃报告工具或日志文件中。有一种理论可能是由于内存压力,但不确定如果iOS在前台终止应用程序,是否会调用applicationWillTerminate。我们在applicationWillTerminate中写入我们的日志文件,但显然在这次崩溃期间没有调用它。 最佳答案 如果应用程序崩溃,则不会可靠地调用任何生命周期方法。相反,您可以创建并注册一个在这种情况下被调用的全局异常处理程序:funcexceptionHandler(exception:NSException){print("**

ios - 如何避免委托(delegate)调用的痕迹

我有一个UIViewController,它有一个UICollectionView,在里面我有一个控制UICollectionViewCell的ListSectionController类>,在该单元格中,我有一个UIView子类。按下按钮时,我需要从UIViewController调用一个方法。目前我有一系列委托(delegate)方法,因为它可以像这样返回到ViewController:classMyView{//delegateisthecellthattheviewiscontainedin@IBActionfuncbuttonPress(){delegate?.myDeleg

ios - 我想在谷歌登录方法中从 App delegate 执行 segue

我已经使用firebase实现了Google登录,但遇到了问题。如果if语句为真,我将尝试从App委托(delegate)执行segue。if语句有效,但每当我运行performsegue方法时,我要么收到信号错误,要么收到嵌入消息的错误访问错误:viewController没有带有标识符“Test”的转场。扩展名用于获取电子邮件的子字符串,顶部的var无关紧要。我知道已经有人问过这个问题,但它对我不起作用,我认为这可能与Google登录有关。我的segues名称是Test。performSegue(withIdentifier:"Wegue",sender:self)用于调用谷歌登录

ios - 为 indexPath 获取 didSelectItemAt 上的值并将其添加到委托(delegate)/协议(protocol)以填充标题单元格

使用协议(protocol)/委托(delegate)并从didSelectItemAt(collectionViews)检索数据。//Thisclasshavethedata//WhereDataIs:UICollectionViewControlleroverridefunccollectionView(_collectionView:UICollectionView,didSelectItemAtindexPath:IndexPath){//PasssomedatafromthedidSelecttoadelegatelettest=things[indexPath.item]g

ios - 从 Swift 框架访问委托(delegate)协议(protocol)到 Objective C

我已经创建了Swift框架并集成到ObjC项目中。现在,我想在ObjC中传递/访问委托(delegate)处理程序。Swift框架包含带有关闭和提交按钮的UIViewController。ListViewController.swiftSwiftFrameworkpublicprotocolListHandler{funcsubmit(options:String)funcclose()}publicclassListViewController:UIViewController{publicvarhandler:ListHandler?@objcfuncdismiss(_sender

ios - 这是一种在 Swift 中将类设置为委托(delegate)的方法吗?

我想将一个类分配给委托(delegate),但它引发了一个错误:预期的成员名称跟在“.”之后我该怎么做?letfrc=NSFetchedResultsController(fetchRequest:fr,managedObjectContext:Utility.managedObjectContext(),sectionNameKeyPath:nil,cacheName:nil)frc.delegate=Utility.class 最佳答案 类不能用作委托(delegate)。委托(delegate)必须是类的实例。没有被实例化的不

ios - 在 View Controller nil 委托(delegate)错误中包装 Collection View

我有一个ViewController包装一个ScrollView,然后包含一个CollectionView和一个内容View。当我运行时,我得到一个空指针异常,在viewDidLoad中分配CollectionView委托(delegate):collectionView.delegate=selfcollectionView.dataSource=selfcollectionView.backgroundColor=UIColor.clearColor()不知道为什么,我已经实现了协议(protocol)并按如下方式连接到ViewController;classLayoutContr