草庐IT

uialertaction

全部标签

ios - 使用 UIAlertControllerStyle.ActionSheet 在 UIAlertController 中取消按钮

我想在我的UIAlert中添加一个单独的取消按钮。我知道如何用UIActionSheet做到这一点,但它也应该可以用UIAlert实现,对吧?varsheet:UIActionSheet=UIActionSheet();lettitle:String="...";sheet.title=title;sheet.delegate=self;sheet.addButtonWithTitle("Cancel");sheet.addButtonWithTitle("...")sheet.cancelButtonIndex=0;sheet.showInView(self.view);这将有一个.

ios - 使用 UIAlertControllerStyle.ActionSheet 在 UIAlertController 中取消按钮

我想在我的UIAlert中添加一个单独的取消按钮。我知道如何用UIActionSheet做到这一点,但它也应该可以用UIAlert实现,对吧?varsheet:UIActionSheet=UIActionSheet();lettitle:String="...";sheet.title=title;sheet.delegate=self;sheet.addButtonWithTitle("Cancel");sheet.addButtonWithTitle("...")sheet.cancelButtonIndex=0;sheet.showInView(self.view);这将有一个.

ios - 在 Swift 中传递空闭包的优雅方式

在Swift中,我经常需要将一个noop闭包传递给一个方法,以符合该方法的预期参数(arity)。在ObjC的美好时光里,可以通过nil进行noop回调并完成它。在Swift中是否有一种更快更优雅的方式来做到这一点,而无需传递如下所示的空block?UIAlertAction(title:"Ok",style:UIAlertActionStyle.Default,handler:{(UIAlertAction)->Voidin})//在回调中什么都不做完整示例:importUIKitclassUIAlertControllerFactory{classfuncok(title:Stri

ios - 在 Swift 中传递空闭包的优雅方式

在Swift中,我经常需要将一个noop闭包传递给一个方法,以符合该方法的预期参数(arity)。在ObjC的美好时光里,可以通过nil进行noop回调并完成它。在Swift中是否有一种更快更优雅的方式来做到这一点,而无需传递如下所示的空block?UIAlertAction(title:"Ok",style:UIAlertActionStyle.Default,handler:{(UIAlertAction)->Voidin})//在回调中什么都不做完整示例:importUIKitclassUIAlertControllerFactory{classfuncok(title:Stri

ios - 如何使用 Swift iOS 向 UIAlertView 按钮添加操作

我想添加另一个按钮,而不是“确定”按钮,它应该只是解除警报。我想让另一个按钮调用某个函数。varlogInErrorAlert:UIAlertView=UIAlertView()logInErrorAlert.title="Ooops"logInErrorAlert.message="Unabletologin."logInErrorAlert.addButtonWithTitle("Ok")我如何向此警报添加另一个按钮,然后允许它在单击后调用一个函数,假设我们希望新按钮调用:retry() 最佳答案 Swifty的方法是使用新的U

ios - 如何使用 Swift iOS 向 UIAlertView 按钮添加操作

我想添加另一个按钮,而不是“确定”按钮,它应该只是解除警报。我想让另一个按钮调用某个函数。varlogInErrorAlert:UIAlertView=UIAlertView()logInErrorAlert.title="Ooops"logInErrorAlert.message="Unabletologin."logInErrorAlert.addButtonWithTitle("Ok")我如何向此警报添加另一个按钮,然后允许它在单击后调用一个函数,假设我们希望新按钮调用:retry() 最佳答案 Swifty的方法是使用新的U

ios - 为 UIAlertAction 编写处理程序

我正在向用户呈现一个UIAlertView,但我不知道如何编写处理程序。这是我的尝试:letalert=UIAlertController(title:"Title",message:"Message",preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"Okay",style:UIAlertActionStyle.Default,handler:{selfinprintln("Foo")})我在Xcode中遇到了很多问题。文档说convenienceinit(titletit

ios - 为 UIAlertAction 编写处理程序

我正在向用户呈现一个UIAlertView,但我不知道如何编写处理程序。这是我的尝试:letalert=UIAlertController(title:"Title",message:"Message",preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"Okay",style:UIAlertActionStyle.Default,handler:{selfinprintln("Foo")})我在Xcode中遇到了很多问题。文档说convenienceinit(titletit

xcode - 带有 OK 和 Cancel : which button tapped? 的 Swift 警报 View

我在Xcode中有一个用Swift编写的警报View,我想确定用户选择了哪个按钮(这是一个确认对话框)什么都不做或执行某事。目前我有:@IBActionfuncpushedRefresh(sender:AnyObject){varrefreshAlert=UIAlertView()refreshAlert.title="Refresh?"refreshAlert.message="Alldatawillbelost."refreshAlert.addButtonWithTitle("Cancel")refreshAlert.addButtonWithTitle("OK")refresh

xcode - 带有 OK 和 Cancel : which button tapped? 的 Swift 警报 View

我在Xcode中有一个用Swift编写的警报View,我想确定用户选择了哪个按钮(这是一个确认对话框)什么都不做或执行某事。目前我有:@IBActionfuncpushedRefresh(sender:AnyObject){varrefreshAlert=UIAlertView()refreshAlert.title="Refresh?"refreshAlert.message="Alldatawillbelost."refreshAlert.addButtonWithTitle("Cancel")refreshAlert.addButtonWithTitle("OK")refresh