草庐IT

UIAlertcontroller

全部标签

ios - 如何从 UIAlertcontroller 中关闭模态 ViewController

我展示了一个模态viewcontroller,用户可以在上面决定编辑或删除呈现的汽车。如果用户想删除这辆车,我会提供一个带有警告样式的UIAlertController来询问他是否真的想删除这辆车。一切正常。但是在用户选择“Yes”之后,我仍然在modalviewcontroller中。删除后如何关闭模态视图?我尝试了以下代码self.parentViewController?.dismissViewControllerAnimated(true,completion:nil)和self.navigationController?.popViewControllerAnimated(t

swift - Xcode 6 或 iOS 8 错误 : UIAlertController Not Showing Message?

在我的ViewController中,我有以下代码来创建UIAlertController:varavc=UIAlertController(title:"Location",message:"PleaseEnterALocation",preferredStyle:UIAlertControllerStyle.Alert)self.navigationController!.presentViewController(avc,animated:true,completion:nil)在模拟器中运行,我明白了确定这是Xcode6beta7或swift中的错误?想法?

swift - 在 Swift 中获取 UIAlertAction 的处理程序

如何在Swift中获取UIAlertAction的处理程序。它是在初始化时设置的,但是我还没有找到任何属性来控制操作的关闭。闭包的类型为(UIAlertAction)->Void但是我想获取闭包的内容,以便我有一些像()->Void这样的闭包。这可能吗?感谢您的回答 最佳答案 我已经为此创建了一个子类,如下所示:///AnUIAlertActionwhichsavesthehandler.Canbeusedforunittestingtheactioncallback.finalclassUIExecutableAlertActio

swift - 无法为扩展方法 UIAlertController 提供参数值

我正在尝试编写一个扩展方法,它根据您提供的参数生成一个UIAlertController。extensionUIAlertController{funcgenerate(messageText:String,messageTitle:String,buttonText:String){letalert=UIAlertController(title:messageTitle,message:messageText,preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:buttonT

ios - 从 UITableViewCell 上的按钮显示 UIAlertController

这是我在UITableViewCell中的按钮内编写的代码。varshareAlert=UIAlertController(title:"PostAlert",message:"YourPosthasbeenSharedwithyourFriends",preferredStyle:UIAlertControllerStyle.Alert)varOk=UIAlertAction(title:"Ok",style:UIAlertActionStyle.Default,handler:nil)shareAlert.addAction(Ok)shareAlert.presentViewCon

ios - 在 Swift 中更改 UIAlertController 上的一个或特定按钮的颜色

我有一个UIController类型的操作表,它显示两个项目,第一个是“从应用程序注销”,另一个是“取消”。我想将显示“从应用程序注销”的按钮的字体颜色更改为红色,并将“取消”按钮保留为默认颜色。我怎样才能做到这一点?下面是我的代码:letcancelActionSheetButton=UIAlertAction(title:"Cancel",style:UIAlertActionStyle.Cancel){(cancelSelected)->Voidinprint("CancelSelected")}letlogoutActionSheet=UIAlertController(tit

ios - 使用 UIWindow() 进行单元测试时出现 NSInternalConsistencyException

我一直在使用followingpost作为如何从与特定UIViewController无关的代码中显示UIAlertController的指南。现在,我想对这段代码进行单元测试:funcshowAlert(alert:UIAlertController,animated:Bool,completion:(()->Void)?){letalertWindow=UIWindow(frame:UIScreen.mainScreen().bounds)//Keepastrongrefencetothewindow.//Wemanuallysetthistonilwhenthealertisdi

swift - UIAlertController 在某些情况下不会被解雇

在我的项目中,将对视频进行处理,然后经过一些效果后播放。在处理视频时,我想显示Pleasewait...消息。我使用UIAlertController显示警报,在完成该过程后我想隐藏警报。如果视频处理正确,警报将被dismissed,但在某些情况下,处理失败的dismiss也将不起作用!请注意,dismiss函数将被调用,但它不起作用。此外,我使用VGPlayer播放视频。classVGViewController:UIViewController{varplayer:VGPlayer?varurl:URL?varoutputVideo:URL?overridefuncviewDidL

swift - 如何使警报只出现一次

我想弄清楚如何创建一个弹出窗口,该窗口仅在您启动该应用程序时出现一次,然后除非您关闭该应用程序并重新启动它,否则不会再次出现。但是,如果您查看下面的代码,您会发现每次ViewController出现时都会弹出警报。例如,如果您转到设置选项卡,然后返回主ViewController,则会弹出警报。overridefuncviewDidAppear(animated:Bool){letalertController=UIAlertController(title:"Disclaimer",message:"WARNING:Pleaseridecarefully!",preferredSty

ios - 在 Swift 3.0 中从异步线程调用 UIAlertController

我有一个IBAction,它调用一个有时会显示来自异步线程的错误警报的函数。它在模拟器中“有效”,但出现此错误:CoreAnimation:warning,deletedthreadwithuncommittedCATransaction;setCA_DEBUG_TRANSACTIONS=1inenvironmenttologbacktraces.看到该错误后,我意识到我正在尝试从主线程更新UI,我需要修复它。这是我正在调用的异步函数:letqueue=DispatchQueue(label:"com.adrianbindc.myApp.myFunction")queue.async{