草庐IT

make_member_delegate

全部标签

ios - 如何在 Swift 的 didReceiveRemoteNotification 上从 App Delegate 推送 View Controller ?

我找不到任何明确的答案,我开始挣扎。到目前为止,我最接近的是present所需的ViewController,但显然它是模态显示的,而不是标签栏或导航栏。我在我的AppDelegate中有didReceiveRemoteNotification函数来尝试处理Firebase推送通知。本质上,我希望能够根据我在Firebase控制台上分配的键值对自动转至我的应用程序中的特定ViewController。到目前为止,我的AppDelegate看起来像这样:应用委托(delegate)funcapplication(_application:UIApplication,didReceiveR

swift - 如何知道调用 Delegate 的 NSCombobox 选择器

我在SWIFT中为OSX应用程序编写了以下代码,代码运行良好(NSComboBox只能选择,不可编辑)我有这两个IBOutletprojNewProjType和projNewRouter,当我更改任一NSComboBox的选择时,我可以看到正确选择的索引值和字符串值但是如何在comboBoxSelectionDidChange()中检查返回的索引值是否来自projNewProjType而不是projNewRouterimportCocoaclassNewProjectSetup:NSViewController,NSComboBoxDelegate{letcomboxProjValue

swift - 在 Swift 3.0 中在 WhatsApp 上共享错误 : Contextual member 'urlHostAllowed' has no associated value

我刚刚将我的swift项目升级到swift3。我一直在使用下面的功能在Whatsapp上分享应用程序,但是我无法理解升级后出现的错误这是函数代码:funcshareOnWhatsapp(){leturlString="Greetings,\n\nThisistheXYZApplink,Ihopeyoufindituseful!\n\nhttp://itunes.apple.com/app/idxxxxxxxx"leturlStringEncoded=urlString.addingPercentEncoding(withAllowedCharacters:.urlHostAllowed

swift - 在通用协议(protocol)上使用委托(delegate)

我有这个代码:protocolGenericProtocol:class{associatedtypetypefuncfunca(component:type)}classMyType{weakvardelegate:GenericProtocol?//Firsterrorvart:Tinit(t:T){self.t=t}funcfinished(){delegate?.funca(component:t)//Seconderror}}classUsingGenericProtocol:GenericProtocol{letmyType:MyTypetypealiastype=Inti

ios - 如何创建具有符合通用协议(protocol)的弱委托(delegate)的基类?

我想为UIView创建一个基类,它要求委托(delegate)符合View定义的特定协议(protocol)。classBaseView:UIView{weakvardelegate:P?}protocolMyProtocol{}classMyView:BaseView{}这给了我错误:“‘weak’不得应用于非类绑定(bind)的‘T’;考虑添加具有类绑定(bind)的协议(protocol)一致性”。如何修复此错误?或者有一些解决方法吗?还是一开始就没有必要让委托(delegate)变量变弱?提前致谢。 最佳答案 由于weak是

ios - 没有 prepareForSegue 的 Swift 委托(delegate)

我是swift和ios开发的新手。我有两个类(class),希望他们联系起来。我没有使用prepareForSegue。这就是我的,一定是哪里出了问题。protocolTimeDelegate{functimerDidFinish()}classTimer:UIViewController{//thisiswherewedeclareourprotocolvardelegate:TimeDelegate?overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview.}over

swift - 在 Swift 中获取错误 Ambiguous reference to member 'subscript'

字典需要扩展以获取文本键值(如果存在)。执行以下代码并成功编译:extensionDictionarywhereKey:ExpressibleByStringLiteral,Value:AnyObject{funcgetValueForKeyPath(keyValue:String)->String{return((self["item_qty"]as?Dictionary)??["":""])?["text"]??""}}但是当我对方法做一些小改动时,出现错误:"Ambiguousreferencetomember'subscript'"extensionDictionarywher

ios - 用户搜索时不调用 AVPlayerViewController 委托(delegate)函数

我一直在尝试在用户搜索时从Avplayerviewcontroller获取通知。我在AvplayerControllerdelegate中找到了一个方法,该方法在用户擦洗时调用,但是该函数未被调用。classViewController:UIViewController,AVPlayerViewControllerDelegate{overridefuncviewDidLoad(){super.viewDidLoad()leturl=URL(string:"https://dl.pagal.link/upload_file/367/382/7491/Bollywood%20MP4%20

ios - 为什么在 SceneKit 中不调用 Contact Delegate?

我正在开发一款游戏,但我遇到了SceneKit中的联系人委托(delegate)问题。我在ViewController中声明了正确的委托(delegate)并使用它来设置委托(delegate):sceneView.scene?.physicsWorld.contactDelegate=self它应该可以工作,事实上,对于XCode6.4它应该可以工作,但对于BetaXCode7它却不能。相同的代码。我的问题是:这里有人知道临时修复方法吗? 最佳答案 从iOS9开始,您必须显式配置physicsBody的“contactTestBi

ios - "Type ' 任务。在 Swift 中键入 ' has no subscript members"错误

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭6年前。Improvethisquestion这段代码给我一个错误;类型'task.Type'没有下标成员这是我的代码:structtask{varname="Un-Named"vardesc="Un-Described"}classTaskManager:NSObject{vartasks=task[]()funcaddTask(name:S