草庐IT

UIAlertcontroller

全部标签

ios - NSNotification:尝试在其 View 不在窗口层次结构中的 ViewController 上显示 UIAlertController

我正在尝试在通过NSNotification调用的函数中的ViewController中显示UIAlertController。但是我收到错误:Attempttopresentonwhoseviewisnotinthewindowhierarchy!NSNotification是从我UI中的其他内容的完成block(我猜是回调)发布的。因为它是一个回调,所以无法显示。因此我想我会尝试NSNotificationCentre来解决这个问题而不使用rootViewController来显示警报。我的代码是:overridefuncviewDidAppear(animated:Bool){/

ios - UIAlertController 不是窗口层次结构

我试图显示一个包含UIPickerView和UITextField的弹出窗口。以下是我用来创建弹出窗口的代码。self.alert=[UIAlertControlleralertControllerWithTitle:nilmessage:@"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"preferredStyle:UIAlertControllerStyleAlert];CGRectpickerFrame=CGRectMake(0,0,270,200);UIPickerView*regionsPicker=[[UIPickerViewalloc]in

swift - 如何设置 UIAlert 显示大量信息?

我想设置一个UIAlert作为用户的“检查”。用户将要保存一组信息,但我想让用户有机会在点击“保存”按钮后查看这些信息。本质上,他们点击“保存”,然后我希望UIAlert出现,显示他们正在保存的信息,询问“你确定所有这些信息都是正确的吗:”然后显示所有信息:@IBActionfuncsaveButtonTapped(_sender:UIBarButtonItem){//createalert(Iknowhowtodothis)thatshowsallinfo(Idon'tknowhowtodothis)//Ifuserisokwiththeinfo,performasegue,ifno

ios - 访问 UIAlertController 的文本字段 - swift ios8

我正在尝试访问UIAlertView的文本字段,我正在使用textFields属性,我从textFields属性获得以下输出:;layer=>如您所见,文本确实出现了,但我需要单独的文本。textFields.text将无法工作,因为它已被弃用并且不能在Swift中使用。 最佳答案 文本字段存储在AnyObject数组中。如果您想访问文本,您应该首先将其转换为UITextField:((alert.textFields[0]asUITextField).text) 关于ios-访问UIA

ios - UIAlertController 在 swift 3 的启动 View 中不工作

我似乎无法在我的View启动时弹出警报View。代码如下。importUIKitclassStartController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()self.view.backgroundColor=UIColor.white;startTest();}funcstartTest(){letalerta=UIAlertController(title:"InvalidTest",message:"Testingalertcontroller",preferredStyle:UIAlertC

ios - 我如何在 UIAlertController 中获取 textField 的值?

这个问题在这里已经有了答案:AccessinputfromUIAlertController(4个答案)关闭去年。我正在尝试从UIAlertController获取一个textField值,但每当我尝试输入该值并尝试将其打印出来时,输出都没有显示任何内容。代码:varalert=UIAlertController(title:"Enterthepassword",message:"Message",preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"Click",style:U

ios - 解除警报时如何弹出到 RootViewController?

@IBActionfuncaddButton(sender:AnyObject){letalert=UIAlertController(title:"NewExerciseAdded",message:"\(name)",preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"Ok!!",style:UIAlertActionStyle.Default,handler:nil))self.presentViewController(alert,animated:true,compl

ios - 如何使 UIAlertController 的消息在 swift2,iOS9 中可复制?

我有一个简单的问题:如何使UIAlertController的消息可供用户选择和复制?Controller是这样启动的:letalertController=UIAlertController(title:"HelloWorld",message:"CopyMe!",preferredStyle:.Alert)并显示如下:presentViewController(alertController,animated:true,completion:nil) 最佳答案 Adam说得对,UIAlertController不提供文本选择功能

image - 快速将图像添加到 UIAlertController

我想要一个带有图像的简单UIAlertController。我该怎么办?letalertMessage=UIAlertController(title:"ServiceUnavailable",message:"Pleaseretrylater",preferredStyle:.Alert)alertMessage.addAction(UIAlertAction(title:"OK",style:.Default,handler:nil))self.presentViewController(alertMessage,animated:true,completion:nil)

ios - 关闭所有当前呈现的 UIAlertControllers

有没有办法关闭当前显示的所有UIAlertController?这是因为在我的应用程序的任何地方和任何状态下,我都需要在按下推送通知时到达某个ViewController。 最佳答案 funcdismissAnyAlertControllerIfPresent(){guardletwindow:UIWindow=UIApplication.shared.keyWindow,vartopVC=window.rootViewController?.presentedViewControllerelse{return}whiletopVC