草庐IT

swift - 如何使用 swift 在应用程序委托(delegate)函数中使用 toast 方法

您好,我正在我的应用程序中使用swift开发应用程序我想使用toast消息和toast事件,所以我点击了链接:https://github.com/scalessec/Toast-Swift.我可以在ViewController方法中使用它运行良好,但我不能在应用程序委托(delegate)方法中使用。我的应用委托(delegate)中的代码:funcloadJsonData(){self.view.makeToastActivity(.center)}上面提到的代码不起作用,因为appdelegate没有成员View...请帮助我在我的appdelegate中使用它。

具有 2 个数据源/委托(delegate)的 iOS Tableview

是否可以让ViewController上的TableView由2个不同的数据源控制?我希望View上的表格根据用户选择的段控制按钮显示不同的表格数据。在目前的状态下,数据源似乎总是最后声明的选项。在这种情况下,missedEventLogController。我是否需要在View中的当前表格之上放置另一个相同的表格?@IBOutletweakvareventLog:UITableView!@IBOutletweakvarmissedEventLog:UITableView!overridefuncviewDidLoad(){self.eventLog.delegate=eventLog

ios - 我需要了解为什么 Objective-C 中的委托(delegate)如此重要,是什么让它如此特别?

所以我已经阅读了很多关于委托(delegate)的解释和实践,但我似乎仍然不明白,我有具体的问题,我希望得到一些有见地的简单答案。为什么在实例方法上使用委托(delegate)?在UIAlertView为什么不直接制作–alertView:clickedButtonAtIndex:将在我的UIAlertView上调用的实例方法实例?委托(delegate)属性是什么?为什么我必须创建委托(delegate)属性并使用奇怪的语法定义它@property(nonatomic,strong)iddelegatedelegate和protocol是硬币的两个面吗?我什么时候知道应该在我的应用中

ios - 为什么不调用 iOS 中的自定义委托(delegate)

我正在尝试使用playground在swift中创建自定义委托(delegate)。但是doSomething方法不是通过回调调用的。delegate?.doSomething()似乎没有触发XYZ类doSomething方法。提前致谢!importUIKit@objcprotocolRequestDelegate{funcdoSomething();optionalfuncrequestPrinting(item:String,id:Int)}classABC{vardelegate:RequestDelegate?funcexecuterequest(){delegate?.doS

ios - 为什么 range.length 值在 shouldChangeCharactersInRange 委托(delegate)方法中因退格而改变?

在我将用户限制为最多24个字符后,我试图弄清楚这一行对退格键的效果如何。但我不知道它是如何工作的。我试图找出range.length的值,如果我插入一些字符,它会设置为0。但是当我在删除字符时按下后退按钮时,我将值设置为1?这是为什么?functextField(textField:UITextField,shouldChangeCharactersInRangerange:NSRange,replacementStringstring:String)->Bool{println("rangeis\(range)")println("rangelocationis\(range.loc

ios - didUpdateLocations 委托(delegate)方法重复随机次数

我在我的方法didUpdateLocations中获取用户的纬度和经度。如果允许位置,我调用一个方法,该方法接受参数纬度、经度并调用web服务,否则我显示一个UIAlertView。问题是:iOS随机调用了我的locationManager委托(delegate)方法。所以我的网络服务被调用了好几次...请问我该如何解决?当我调用该位置时,验证是否允许...我在上一个屏幕中提出请求://GETLOCATIONself.initializeWaitingScreen()if(CLLocationManager.authorizationStatus()==CLAuthorizationS

ios - 为什么我们不用委托(delegate)对象来实例化委托(delegate)类呢?

我无法想象没有委托(delegate)的委托(delegate)下载器类或CLLLocationManager或tableView。那么,为什么我们需要将其创建为可选项?我们为什么要这样做tableview=UITableView()tableview.delegate=selftableview.dataSource=self为什么没有制作API,所以我们可以这样做:tableview=UITableView(delegate:self,dataSource:self)这是不是因为内存循环,所以我们可以先nil委托(delegate)类或委托(delegate)类然后另一个?这是唯一

ios - MFMailComposeViewController 不发送电子邮件或调用委托(delegate) (MFMailComposeViewControllerDelegate)

我有一个MFMailComposeViewController设置并显示如下:classMyViewController:UIViewController{//MARK:-PropertiesletcomposeViewController=MFMailComposeViewController()//MARK:-Actions@IBActionfuncdidTapSendInEmailButton(){composeViewController.mailComposeDelegate=selfcomposeViewController.setToRecipients([Constan

ios - 在 UIView 子类中声明的委托(delegate)在 UIViewController 中不起作用?

我正在尝试创建一个可重用的UIView,我可以将其放置在多个UIViewController中。我给了它委托(delegate)方法,我希望父UIViewControllers访问它,但它抛出一个错误(在下面的代码中注释)。有什么更好的方法可以解决这个问题?importUIKitclassViewController:UIViewController{@IBOutletweakvarcameraView:CameraView!overridefuncviewDidLoad(){super.viewDidLoad()self.cameraView.delegate=self//ERROR

ios - 无法覆盖 Swift 中的委托(delegate)属性

我正在尝试制作一个类似于ImagePickerController的StudentPickerController:classStudentPickerController:UINavigationController,NSCoding{unowned(unsafe)vardelegate:protocol?}@objcprotocolStudentPickerControllerDelegate:NSObjectProtocol{optionalfuncstudentPickerControllerDidFinishPickingStudent(student:Student)opt