草庐IT

Delegate

全部标签

iphone - iOS:如何识别我们从父 UIViewController 中的子 UIViewController 返回?

假设我在UINavigationController中的堆栈上有2个UIViewController。在“parent”中,我们称之为“[self.navigationControllerpushViewController:childViewControlleranimated:YES];”根据某些用户操作,在“子”中我们调用“[self.navigationControllerpopViewControllerAnimated:YES];”根据一些用户操作。我们如何在父对象中识别出我们刚回来?是否有一些“事件”驱动的方法可以识别这个popViewControllerAnimated

面试常考:C# 委托(delegate、Action、Func、predicate)和事件

面试常考:C#委托(delegate、Action、Func、predicate)和事件刚开始工作的时候,觉得委托和事件有些神秘,而当你理解他们之后,也觉得好像没有想象中的那么难,这篇博文算是自己对委托和事件的一次梳理和总结。二、委托C#中的委托,相当于C++中的指针函数,但委托是面向对象的,是安全的,是一个特殊的类,当然他也是引用类型,委托传递的是对方法的引用。2.1、delegate声明委托就必须使用关键字“delegate”,委托是先声明,后实例化。至少0个参数,至多32个参数格式如下所示:privatedelegatestringGetAsString();委托是一个类,所以他的实例化

iPhone - MFMailComposeViewController 委托(delegate)不兼容的类型

我有一个ViewController,它以模态方式打开MFMailComposeViewController。当我尝试将邮件ViewController的委托(delegate)设置为父ViewController时,我收到此警告:Assigningto'id'fromincompatibletype'MoreViewController*__strong'父ViewController在其接口(interface)声明中肯定有MFMailComposeViewControllerDelegate并且正在实现委托(delegate)方法-mailComposeController:di

iPhone - MFMailComposeViewController 委托(delegate)不兼容的类型

我有一个ViewController,它以模态方式打开MFMailComposeViewController。当我尝试将邮件ViewController的委托(delegate)设置为父ViewController时,我收到此警告:Assigningto'id'fromincompatibletype'MoreViewController*__strong'父ViewController在其接口(interface)声明中肯定有MFMailComposeViewControllerDelegate并且正在实现委托(delegate)方法-mailComposeController:di

objective-c - UITextView 子类作为自身的委托(delegate)

假设我向我的UIView添加了一个UITextView,并且我希望它在每次内容更改时更改其背景颜色。我可以通过成为UITextView的委托(delegate)并实现textViewDidChange来实现这一点。如果我经常使用这种行为,那么创建一个UITextView子类是有意义的,我将其称为ColorSwitchingTextView。它应该包括默认的颜色切换行为,这样任何UIView都可以简单地添加它而不是标准的UITextView如果它想要这种行为。如何从我的ColorSwitchingTextView类中检测内容的变化?我不认为我可以做类似self.delegate=self

objective-c - UITextView 子类作为自身的委托(delegate)

假设我向我的UIView添加了一个UITextView,并且我希望它在每次内容更改时更改其背景颜色。我可以通过成为UITextView的委托(delegate)并实现textViewDidChange来实现这一点。如果我经常使用这种行为,那么创建一个UITextView子类是有意义的,我将其称为ColorSwitchingTextView。它应该包括默认的颜色切换行为,这样任何UIView都可以简单地添加它而不是标准的UITextView如果它想要这种行为。如何从我的ColorSwitchingTextView类中检测内容的变化?我不认为我可以做类似self.delegate=self

ios - Objective-C 中的多个 NSURLConnection 委托(delegate)

我有两个NSURLConnections。第二个取决于第一个的内容,因此处理从连接接收到的数据对于两个连接来说是不同的。我刚开始学习Objective-C,我想知道实现委托(delegate)的正确方法是什么。现在我正在使用:NSURL*url=[NSURLURLWithString:feedURL];NSURLRequest*urlR=[[[NSURLRequestalloc]initWithURL:url]autorelease];NSURLConnection*conn=[[NSURLConnectionalloc]initWithRequest:urlRdelegate:sel

ios - Objective-C 中的多个 NSURLConnection 委托(delegate)

我有两个NSURLConnections。第二个取决于第一个的内容,因此处理从连接接收到的数据对于两个连接来说是不同的。我刚开始学习Objective-C,我想知道实现委托(delegate)的正确方法是什么。现在我正在使用:NSURL*url=[NSURLURLWithString:feedURL];NSURLRequest*urlR=[[[NSURLRequestalloc]initWithURL:url]autorelease];NSURLConnection*conn=[[NSURLConnectionalloc]initWithRequest:urlRdelegate:sel

ios - Storyboard弹出窗口已关闭,未调用委托(delegate)方法

我有一个ViewController,它使用Storyboard转场显示在弹出窗口中。在呈现ViewController中,我有以下代码:overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){ifletsvc=segue.destinationViewControlleras?SettingsViewController{svc.popoverPresentationController?.delegate=self}}然而,事实证明,呈现的ViewController,即使它显示为弹出窗口,也具有

ios - Storyboard弹出窗口已关闭,未调用委托(delegate)方法

我有一个ViewController,它使用Storyboard转场显示在弹出窗口中。在呈现ViewController中,我有以下代码:overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){ifletsvc=segue.destinationViewControlleras?SettingsViewController{svc.popoverPresentationController?.delegate=self}}然而,事实证明,呈现的ViewController,即使它显示为弹出窗口,也具有