草庐IT

UIAlertcontroller

全部标签

xcode - Swift UIAlertController 获取文本字段文本

我需要在按下“输入”按钮时从警报View中的文本字段中获取文本。funcinputMsg(){varpoints=""varoutOf=""varalertController=UIAlertController(title:"InputView",message:"PleaseInputYourGrade",preferredStyle:UIAlertControllerStyle.Alert)letactionCancle=UIAlertAction(title:"Cancle",style:UIAlertActionStyle.Cancel){ACTIONinprintln("C

ios - 在 Swift 中为 UIAlertController 设置背景颜色

我正在使用新的UIAlertController为我的应用程序实现各种选项菜单。我试图让UIAlertController的背景颜色与我的应用程序其余部分的主题相匹配。我的应用程序的主题非常简单,由带有蓝色/灰色背景色的白色文本组成,用于工具栏和导航栏,如下所示:但是,我在尝试让我的UIAlertController符合这个主题时遇到了一些麻烦。我进行了以下两次调用来设置文本和背景颜色:uiAlertController.view.backgroundColor=UIColor(red:CGFloat(.17255),green:CGFloat(.24314),blue:CGFloat

ios - 扩展 UIAlertController 便利初始化警告

当我定义一个UIAlertControllerconvenienceinitializer时:extensionUIAlertController{convenienceinit(message:String?){self.init(title:nil,message:message,preferredStyle:.Alert)self.addAction(UIAlertAction(title:"OK",style:.Cancel,handler:nil))}}并在我的UIViewController子类中的按钮操作中使用它:funcbuttonAction(button:UIBut

swift - 添加文本字段 MDCAlertController IOS

Uialertcontroller中没有类似addtextfield方法的方法。我还没有找到任何有关如何自定义MDCAlertControllers的示例。有人有想法吗? 最佳答案 我认为这是不可能的。docs说:MDCAlertControllerclassisintendedtobeusedas-isanddoesnotsupportsubclassing.Theviewhierarchyforthisclassisprivateandmustnotbemodified. 关于swi

ios - 如果调用另一个 Alert Controller 以显示,则删除 Alert Controller

我的应用需要在不同时间向用户显示一些信息。我决定使用AlertControllers但我不能同时显示两个AlertControllers。因此我需要知道是否显示了警报Controller,关闭它并打开另一个。到目前为止我已经做到了。我正在使用self.presentedViewController检查是否显示了AlertController。但我不知道如何关闭它。我试过self.presentedViewController?.removeFromParentViewController()和self.presentedViewController?.delete(self.prese

ios - 未调用 UIAlertAction 处理程序

我有一个UITableView并且在委托(delegate)(ViewController)中,我已经实现了函数tableView(tableView:UITableView,commitEditingStyleeditingStyle:UITableViewCellEditingStyle,forRowAtIndexPathindexPath:NSIndexPath)然后我测试编辑风格ifeditingStyle==UITableViewCellEditingStyle.Delete{//dodeletingstuffhere}作为删除的一部分,我请求用户确认,如果他们选择"is",

ios - 在不更改状态栏颜色的情况下呈现 View Controller ,例如 UIAlertController

在执行某些网络操作时,我会提供一个模态视图Controller(类似于MBProgressHUD,但作为ViewController)以防止用户交互并指示进度。ViewController具有modalPresentationStyle=.Custom并使用转换委托(delegate)和自定义呈现Controller进行动画处理。除了动画转换之外,他们没有驱动演示的自定义操作。我遇到的问题是,无论何时呈现ViewController,它都会将状态栏颜色变为黑色。我可以重写preferredStatusBarStyle以使其始终返回.LightContent但有时此ViewControl

ios - Swift 自定义 UIAlertView

我正在尝试创建确认删除弹出View。因为我想要的设计与典型的UIAlertView弹出窗口的样式非常不同,所以我决定创建一个自定义的ConfirmationViewController来触发弹出窗口。这是典型的UIAlertView的样子:这是我希望我的样子:这是我目前制作自定义ConfirmationViewController弹出窗口的方式:letconfirmationViewController=ConfirmationViewController()confirmationViewController.delegate=selfconfirmationViewControll

iphone - 自动关闭 UIAlertController

我的应用程序有一个UILongPressGestureRecognizer,当用户触摸屏幕上的两个元素时,它会显示带有UIAlertController的警报。目前,用户必须按下OK按钮才能关闭警报,但我想在0.5秒后自动关闭警报,这样用户就不会影响他与应用程序的交互。有什么办法吗? 最佳答案 可以通过GCD的dispatch_after实现alertview的自动dismiss。试试下面的代码:letdelay=0.5*Double(NSEC_PER_SEC)lettime=dispatch_time(DISPATCH_TIME_

swift - 如何从 UIAlertController 的 UIAlertAction 处理程序中关闭 UIViewController?

我想向用户展示一个简单的UIAlertController,其中一个选项会触发父ViewController的关闭。这是我正在使用的代码:letalert=UIAlertController(title:title,message:message,preferredStyle:UIAlertControllerStyle.Alert)alert.addAction(UIAlertAction(title:"CloseView",style:UIAlertActionStyle.Destructive,handler:{actioninself.dismissViewController