草庐IT

UIAlertcontroller

全部标签

ios - 将图像添加到 UIAlertController

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭7年前。Improvethisquestion我想向UIAlertController添加图像。图像不需要在按钮上,只需呈现在Controller中间即可。我的代码在下面,但崩溃并显示消息“无法识别的选择器已发送到实例”。funcshowAlert(){letalert=UIAlertControl

ios - 如何快速覆盖 UIAlertController 中的便利初始化?

我试图覆盖UIAlertController中的便利初始化,但它给我一个错误,如“初始化器没有覆盖其父类(superclass)中的指定初始化器”。我如何使用继承或扩展覆盖它?我的代码如下。importUIKitclassColorAlertViewController:UIAlertController{overridefuncviewDidLoad(){super.viewDidLoad()}overridefuncdidReceiveMemoryWarning(){super.didReceiveMemoryWarning()}overrideconvenienceinit(ti

ios - 使用 UIAlertController 按钮将自定义单元格添加到 tableView

我创建了一个UITableView并创建了一些单元格并为它们指定了标识符。我还创建了一个UIAlertController来在同一个ViewController上按下按钮时显示弹出窗口。我希望能够根据用户在警报弹出窗口中点击的按钮,使用适当的单元格将新行插入到表中。帮助? 最佳答案 你可以这样试试letalert=UIAlertController(title:"Test",message:"Message",preferredStyle:UIAlertControllerStyle.alert)alert.addAction(UI

swift - UIAlertController 取消完成永远不会被调用

在下面的代码中,当我的WebView无法加载时,警报会按预期正确显示并带有重试按钮。点击重试按钮时警报消失,但永远不会调用完成。这是为什么?funcwebView(_webView:UIWebView,didFailLoadWithErrorerror:Error){letalert=UIAlertController(title:"NetworkError",message:"Therewasaerrorloadingthepage.",preferredStyle:.alert)alert.addAction(UIAlertAction(title:"Retry",style:.d

swift - UIAlertAction 在其回调中关闭 UIAlertController

这个问题在这里已经有了答案:PreventdismissalofUIAlertController(5个答案)关闭8年前。我正在尝试使用iOS8中引入的新UIAlertController。一切都很好,除了UIAlertAction总是在其回调中关闭警报Controller。以下是我的代码:letalert=UIAlertController(title:"NewGroup",message:"EnterGroupname",preferredStyle:UIAlertControllerStyle.Alert);alert.addTextFieldWithConfigurationH

ios - 在 SWIFT 中为 UIAlertController 设置标签?

如何在swift中为警报View设置标签。我无法设置标签alert.tag=1,如果设置了,我会收到类似'UIAlertController'doesnothaveamembernamed'tag'的错误。下面是我写的代码,varalert=UIAlertController(title:"Title",message:"Message",preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"YES",style:UIAlertActionStyle.Default,handle

ios - 为什么我的 UIAlertController 中的选项变暗,我该如何解决?

这很奇怪。我正在使用以下代码制作一个UIAlertController:letoptionMenu=UIAlertController(title:nil,message:"ChooseOption",preferredStyle:UIAlertControllerStyle.ActionSheet)letaction=UIAlertAction(title:"Action1",style:.Default,handler:{(alert:UIAlertAction!)->Voidinprint("Cancelled")})letaction2=UIAlertAction(title:

ios - 如何锁定 UIAlertController 方向?

在我的应用程序中,我只有一个横向模式的UIViewController,如果我在应用程序内导航,它工作正常。但是,当我从横向ViewController显示UIAlertController(用于显示警报View)并更改设备方向时,它会更改横向ViewController的方向。我尝试了不同的解决方案,例如:UIAlertViewcrashsiniOS8.3iOS8.3supportedorientationscrashs但这些都不适合我。如何锁定UIAlertController的方向?注意:我的应用支持iOS9。 最佳答案 这是

UIAlertController/UIAlertView 的 iOS/Swift 测试

我正在开发一个需要在iOS7和8上运行的应用程序。如果可能,我想使用UIAlertController,如果不能回退到UIAlertView。我用这个测试:letgotUIAlertController:AnyClass?=NSClassFromString("UIAlertController")if(gotUIAlertController!=nil){//DoUIAlertController}else{//DOUIAlertView}这似乎适用于iOS8模拟器,在Debug模式下,但在Release模式下(或使用仪器运行Debug模式)时,gotUIAlertControlle

ios - UIAlertController 按钮功能不起作用

letlocation=CLLocationCoordinate2D(latitude:32.075300,longitude:34.782563)@IBActionfuncDirectionsTolocationButton(_sender:Any){//CreatetheAlertControllerandadditsactionslikebuttoninActionSheetletActionSheet=UIAlertController(title:"PleaseSelectANavigationService.",message:nil,preferredStyle:.act