草庐IT

make_member_delegate

全部标签

ios - UItextView 委托(delegate) swift - textViewDidBeginEditing 未调用

我看过其他关于UITextView委托(delegate)的主题,但似乎无法找到我的问题出处。这是我的代码,但是当我修改我的UITextView时,没有任何反应,也没有调用textViewDidBeginEditing。importUIKitvartextView1=UITextView()classViewController:UIViewController,UITextViewDelegate{overridefuncviewDidLoad(){super.viewDidLoad()textView1.delegate=selftextView1=UITextView(frame

objective-c - 使用 "member"获取 Set 中的元素

我是Swift的新手,我正在尝试将一段Objective-C代码重写成Swift语言。原始代码是修改Set中的一个元素:@property(nonatomic,strong,nonnull)NSMutableSet*itemsSet;...CustomItem*item=[[CustomItemalloc]initWithSomething:something];CustomItem*existingItem=[self.itemsSetmember:item];if(existingItem){existingItem.property=3}Swift代码看起来像这样:varitem

ios - 检查可选的多参数委托(delegate)方法

Swift新手。如果(a)设置了委托(delegate)并且(b)实现了方法,则努力寻找最简洁/惯用的语法来调用可选的委托(delegate)方法。我知道?可以扮演这个角色(例如self.delegate.foo?()),但我在尝试调用ObjC时无法获得正确的语法具有多个参数并返回一个我关心捕获的值(Bool)的委托(delegate)方法(我想区分“未实现的方法”和“已实现并返回false的方法”)。这是一个例子。在这种情况下,MyDelegateProtocol有一个可选方法-myThing:argTwo:argThree:(返回Bool)。这段代码似乎语义正确,但它使用了resp

ios - 试图导出到 csv 但我如何从委托(delegate)中实现?

[swift的新手]我测试这个函数来导出一些简单的文件@IBActionfuncexportFile(delegate:UIDocumentInteractionControllerDelegate){print("exportcsv")letfileName=tmpDir.stringByAppendingPathComponent("myFile.csv")leturl:NSURL!=NSURL(fileURLWithPath:fileName)ifurl!=nil{letdocController=UIDocumentInteractionController(URL:url)d

ios - 收到错误 : Type 'String' has no member 'foregroundColor' in Swift 4

我是Swift的新手。我在Swift4中创建了一个应用程序,但是当我将SWIFT_VERSION更改为Swift3.0时,我的代码出现错误。Type'String'hasnomember'foregroundColor'.如何将其转换为当前的Swift语法?代码:ifletp=placeholder{letplace=NSAttributedString(string:p,attributes://error-->[.foregroundColor:#colorLiteral(red:1.0,green:1.0,blue:1.0,alpha:1.0)])attributedPlaceh

ios - 动画委托(delegate)未转换为 Swift 3.0

我想实现CABasicAnimation并在动画完成时通知UIViewController。来自这个资源:http://www.informit.com/articles/article.aspx?p=1168314&seqNum=2我知道我可以将viewcontroller指定为动画的委托(delegate)并覆盖viewcontroller中的animationDidStop方法。但是,当我将以下代码行转换为Swift时:[animationsetDelegate:self];像这样:animation.delegate=self//没有setDelegate方法XCode提示:C

ios - SWIFT iOS 中未调用委托(delegate)

我创建了2个View,一个是使用协议(protocol)和委托(delegate)。对于第一个View,未调用委托(delegate)函数。我的FirstViewController:我在这里访问委托(delegate)函数。importUIKitclassNextViewController:UIViewController,DurationSelectDelegate{//varsecondController:DurationDel?varsecondController:DurationDel=DurationDel()@IBActionfuncNext(sender:AnyO

uitextfield - UIAlertController 的文本字段委托(delegate)未被调用

我已将UITextField添加到UIAlertController,但shouldChangeCharactersInRange不会被触发。为什么?我设置委托(delegate)。letalertController=UIAlertController(title:"",message:"xxx",preferredStyle:.Alert)self.presentViewController(alertController,animated:true,completion:nil)lettextField=UITextField()textField.delegate=selfal

swift - 错误 : 'Delegate must respond to locationManager:didUpdateLocations:' when collecting user location

所以我想在用户点击按钮时收集用户位置,并稍后在我的应用程序中使用该位置。在我当前的实现中,当点击按钮时,应该提示用户允许共享位置,然后他们应该登录到应用程序(如果你想知道的话,通过Firebase匿名登录),并且应该打印用户位置信息到控制台。提示有效,但是在点击允许位置按钮后,我的应用程序终止duetouncaughtexception'NSInternalInconsistencyException'原因是'DelegatemustrespondtolocationManager:didUpdateLocations:'这很奇怪,因为我的代码中确实有一个didUpdateLocati

ios - 错误 : Value of type string has no member componentsSeparatedByCharactersInSet

以下代码抛出以下错误:“字符串类型的值没有成员componentsSeparatedByCharactersInSet”此代码来自之前在swift版本1或2中运行但不再运行的另一个项目。importFoundationextensionString{funcsplit()->[String]{returnself.componentsSeparatedByCharactersInSet(CharacterSet.whitespaceAndNewlineCharacterSet()).filter({$0!=""});}}extensionArray{funcunique()->[T]{