草庐IT

delegating-constructor

全部标签

ios - 未调用 alertViewShouldEnableFirstOtherButton 委托(delegate)方法

我想显示一条警告消息,我正在使用iOSSDK8.1和XCode6.1。我知道UIAlertView已被弃用;但是,我的应用程序还必须支持iOS7,如果该应用程序在iOS7设备上运行,我必须使用UIAlertView。此警报View有一个文本字段和两个按钮,其中一个是默认取消按钮。只要文本字段为空,另一个按钮就应该被禁用。这是我的代码:classMyViewController:UIViewController,UIAlertViewDelegate{varaddRecipientAlertView:UIAlertView?//IrrelevantcodeherefuncperformS

ios - 未调用 didOutputSampleBuffer 委托(delegate)

我的代码中的didOutputSampleBuffer函数没有被调用。我不知道为什么会这样。这是代码:importUIKitimportAVFoundationimportAccelerateclassViewController:UIViewController{varcaptureSession:AVCaptureSession?vardataOutput:AVCaptureVideoDataOutput?varcustomPreviewLayer:AVCaptureVideoPreviewLayer?@IBOutletweakvarcamView:UIView!overridef

swift - swift Playground 中的简单 swift 委托(delegate)

我对Swift和一般编程还很陌生,对Fortran77有点了解,最近对微Controller进行了一些简单的编程。我正在研究基础知识,一切都很好,直到我遇到一些我无法完全掌握的东西-委托(delegate)。所有的在线帖子都没有完全理解这个概念,至少对我来说是这样,所以为了给自己一些我可以引用的东西,我在Playground上设置了一个基本模板,如下所示。如果我运行下面的代码,它会工作并向终端打印“完成的事情”,但是如果我将协议(protocol)设为“类”协议(protocol),即“协议(protocol)SomeDelegate:类{”,并将“vardelegate”设为“wea

ios - 如何在 Swift 中将 dataSource 和 delegate 从 viewController 类中分离出来?

我试图将dataSource和delegate与viewController分开,以防止viewController变得困惑。我阅读了一些帖子,发现我可以像下面这样分离数据源,创建一个类来表示dataSource:importUIKitclassDataSource:NSObject,UITableViewDataSource,UITableViewDelegate{varmovies=[String]()//MARK:-UITableViewDataSourcefuncnumberOfSectionsInTableView(tableView:UITableView)->Int{re

ios - 自定义 UIView 初始化程序的便利初始化程序必须使用 self.init 错误进行委托(delegate)

我正在尝试为UIView创建自定义初始化方法,如下所示:convenienceinit(frame:CGRect,tutorProfileImageURL:String?){self.tutorProfileImageURL=tutorProfileImageURLsuper.init(frame:frame)}overrideinit(frame:CGRect){super.init(frame:frame)setup()}requiredinit?(coderaDecoder:NSCoder){super.init(coder:aDecoder)setup()}funcsetup(

iOS Delegate 未设置并返回 nil (Swift)

当我尝试设置委托(delegate)时,结果为nil,并且无法弄清楚为什么委托(delegate)未正确设置。我有一个ViewControllerListViewController,我向其添加了一个subviewmusicPlayer。musicPlayer是一个UIView,它有一些按钮,点击时应该触发ListViewController中的操作。musicPlayer是这样设置的:protocolMusicPlayerControlsDelegate{funcplayPauseClicked()}classmusicPlayer:UIView{varmyDelegate:Musi

ios - willDisplayCell 委托(delegate)方法 Swift

我一直在围绕tableview工作,但遇到了以下问题。据我所知,willDisplayCell委托(delegate)方法应该允许我访问当前的单元格设计。我的问题是-我无法访问的实例自定义单元格,因为它是在cellForRowAtIndexPath方法中单独声明的。如果我再次声明它-我无法访问它的对象(我在那里有一个uibutton)。或者我可能误解了这种方法的使用。这是我的代码functableView(tableView:UITableView,willDisplayCellcell:UITableViewCell,forRowAtIndexPathindexPath:NSInde

ios - UITabBarController 动画的转换委托(delegate)

我已经创建了一个自定义的UIViewControllerAnimationTransition类,并且需要在它切换选项卡时使它成为UITabBarController的动画。不过,tabBarController不使用常规标签栏。我有一个类似它的自定义实现,当按下按钮时,它会调用此代码:tabBarController.selectedIndex=index目前我有tabBarController(子类)作为它自己的transitionDelegate的委托(delegate)。不过,委托(delegate)方法animationControllerForPresentedContro

ios - 从基类扩展委托(delegate)

我有一个objc基类:@protocolBaseClassDelegate;@interfaceBaseClass:NSObject@property(nonatomic,weak)iddelegate;@end@protocolBaseClassDelegate-(void)baseDelegateMethod;@end我正在创建一个swift子类,我想在其中扩展我的委托(delegate)...protocolSubClassDelegate:BaseClassDelegate{funcadditionalSubClassDelegateMethod();}classSubClas

ios - 单击按钮时 UITextField 不会结束编辑(委托(delegate) textFieldDidEndEditing)

我在屏幕上有两个textFields和一个Submit按钮。用户在第一个文本字段中输入详细信息,然后在第二个文本字段中输入详细信息。我的要求是在单击Submit按钮时结束编辑,并打印这些textFields中的用户输入。我在打印第二个textField的值时遇到问题,因为当用户单击提交按钮时,编辑似乎永远不会结束。这是我的代码。感谢您在此问题上的帮助(我添加了文本字段委托(delegate))importUIKitclassViewController:UIViewController,UITextFieldDelegate{varfirstName=""varlastName=""@