草庐IT

def_delegate

全部标签

iphone - UIActionSheet 委托(delegate)方法未被调用

我有一个操作表,它似乎只在我单击"is"按钮时调用clickedButtonAtIndex委托(delegate)方法,而不是在“否”按钮上...这是代码:self.myActionSheet=[[UIActionSheetalloc]initWithTitle:@"Test"delegate:selfcancelButtonTitle:@"No"destructiveButtonTitle:@"Yes"otherButtonTitles:nil];[self.myActionSheetshowInView:self.view];[myActionSheetrelease];然后是委托

ios - 委托(delegate)是否仍然不安全未保留?

我正在阅读BNR第3版,它说delegate默认是unsafeunretained而不是weak为了向后兼容。我想知道对于最新版本的Xcode是否仍然如此,因为不再有多少人使用旧的iOS版本了? 最佳答案 iOS5.0及更高版本支持委托(delegate)空化。如果您的目标是5.0或更高版本,请使用weak。 关于ios-委托(delegate)是否仍然不安全未保留?,我们在StackOverflow上找到一个类似的问题: https://stackoverf

ios - 是否有必要将一个对象声明为委托(delegate)来使用它?

我用调用类作为委托(delegate)创建了一个NSURLConnection。在意识到我从未将对象声明为遵守协议(protocol)之前,我将其构建到我的测试设备上,但它运行了(我会说正常,但我认为我完全围绕多线程搞砸了我的应用程序)。那么是否没有必要将对象声明为实现委托(delegate)?我也没有包含所有需要的委托(delegate)方法,它仍然调用了委托(delegate)方法。这个项目还有其他人,而且它相当大,所以委托(delegate)协议(protocol)可能在某个模糊的地方声明,但我在header和实现声明中搜索时没有看到它。 最佳答案

ios - GADInterstitial 未在 iOS 上触发任何委托(delegate)方法

我正在尝试将AdMob的插页式广告集成到我的iOS中,但即使一切看起来都正常,我也没有触发任何插页式委托(delegate)​​方法(包括失败)。我已将我的广告设置为插页式广告并且我的广告单元ID正确。这是我的代码:GADInterstitial*interstitialAd=[[GADInterstitialalloc]init];interstitialAd.adUnitID=AD_UNIT_ID;interstitialAd.delegate=self;GADRequest*adRequest=[GADRequestrequest];#ifDEBUGadRequest.testD

ios - UICollectionView 单元格的自定义委托(delegate) - 自定义按钮不起作用

我有一个从UIcollectionViewCell子类化的自定义单元格。通过代码,我创建了按钮并使用同一类中的目标方法将其添加到单元格中。按钮事件工作正常。但是我需要控制我创建UICollectionView的基本View。为此,我创建了用于识别点击事件的自定义委托(delegate)。--->DBDraggingCell.h文件@protocolDBDraggingCellDelegate-(void)chartButtonpressed:(id)sender;-(void)accountHistoryButtonpressed:(id)sender;-(void)transacti

ios - block 可以用作委托(delegate)的替代品吗?

我想编写一个自定义委托(delegate)方法以在我的一个ViewController中接收来自另一个ViewController的事件。我应该在这里使用block而不是委托(delegate)吗?哪个是首选?@protocolMyClassDelegate-(void)doSomethingInDelegate;@end@interfaceMyClass:NSObject@propertyiddelegate;-(void)doSomething@end@implementationMyClass-(void)doSomething{[self.delegatedoSomething

ios - 如果 View 不在 View 层次结构中,则不调用 GADBannerView 委托(delegate)方法

我正在iOS上使用Google移动广告SDK并尝试展示一些广告。我的代码:GADBannerView*bannerView=[[GADBannerViewalloc]initWithAdSize:GADAdSizeFromCGSize(CGSizeMake(300,250))];bannerView.adUnitID=@"hidden";bannerView.rootViewController=self;bannerView.delegate=self;GADRequest*request=[GADRequestrequest];request.testDevices=@[kGADS

ios - 如何处理 Swift 3 中 UNUserNotificationCenter 和 FIRMessaging w/Firebase 的委托(delegate)?

我正在尝试使用Firebase在我的应用程序中实现推送通知,但是在按照他们的文档进行操作时,我必须添加以下代码行:if#available(iOS10.0,*){letauthOptions:UNAuthorizationOptions=[.alert,.badge,.sound]UNUserNotificationCenter.current().requestAuthorization(options:authOptions,completionHandler:{_,_in})UNUserNotificationCenter.current().delegate=selfFIRMe

ios - 设置 self.delegate = self 是不是糟糕的设计

我有一个UIViewController子类(比如MyViewController)。MyViewController.h@protocolTargetChangedDelegate-(void)targetChanged;@end@interfaceMyViewController@property(weak)idtargetChangedDelegate;-(void)doSomethingOnYourOwn;@endMyViewController.m@implementationMyViewController-(void)doSomethingOnYourOwn{//DOso

ios - 为什么将 UITextField 委托(delegate)分配给自身时会出现错误?

我正在做以下事情:self.firstNameTextField.delegate=self.firstNameTextField;我的firstNameTextField是一个自定义文本字段。我希望自定义文本字段处理所有委托(delegate)事件。当我执行上述操作时,我收到以下警告:AssigningtoidfromincompatibletypeUITextField.这个警告是关于什么的,我该如何删除它? 最佳答案 您的自定义UITextField类需要表明它符合UITextFieldDelegate协议(protocol)