Tag: uialertcontroller

如何在全局swift中创builduialertcontroller

我正在尝试在Config.swift文件中创builduialertcontroller ,如下所示。 static func showAlertMessage(titleStr:String, messageStr:String) -> Void { let window : UIWindow? let alert = UIAlertController(title: titleStr, message: messageStr, preferredStyle: UIAlertControllerStyle.Alert); self.window!.presentViewController(alert, animated: true, completion: nil) } 问题是我在self.window!.发现问题self.window!. input'Config'没有成员'window' 请让我知道如何解决这个问题。

如何将进度条添加到UIAlertController?

我想在swift iOS 8 UIAlertController中添加进度条。 这可能吗? 有没有办法inheritanceUIAlertController并添加progres栏和连接一些委托function? 谢谢

SWIFT – 添加图像以提醒视图

我有一个警告视图,当用户按下添加button时popup。 如何将图像添加到警报视图? 我添加了一些我从堆栈溢出引用的代码。 我的保存button被replace为图像,图像显示为蓝色… 警报视图代码 var alert = UIAlertController(title: "Spring Element \(springNumber)", message: "Add spring properties", preferredStyle: .Alert) let saveAction = UIAlertAction(title: "Save", style: .Default) { (action: UIAlertAction!) -> Void in let textField1 = alert.textFields![0] as UITextField self.txtField1.append(textField1.text) self.tableView.reloadData() let textField2 = alert.textFields![1] as UITextField self.txtField2.append(textField2.text) self.tableView.reloadData() println(self.txtField1) println(self.txtField2) } let cancelAction = UIAlertAction(title: "Cancel", […]

UIAlertAction处理程序在延迟之后运行

我试图将我的UIAlertViews更改为UIAlertControllers。 我为此设置了这个动作: UIAlertAction *undoStopAction = [UIAlertAction actionWithTitle:@"Undo Stop" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self undoStop]; }]; 但是,处理程序不会运行,直到动作被点击后一秒左右。 有什么办法可以加速吗?

警告:尝试在<…>上呈现<UIAlertController:0x7facd3946920>(已经呈现)(null)

我在UITableView上设置了一个长按手势,提供了一个包含单元格文本的UIAlertController 。 当UIAlertController出现时,我得到这个警告: Attempt to present <UIAlertController: 0x7fd57384e8e0> on <TaskAppV2.MainTaskView: 0x7fd571701150> which is already presenting (null) 从我的理解,MainTaskView( UITableView )已经呈现一个视图,所以它不应该提供第二个视图, UIAlertController. 所以我从类似的问题尝试了这个解决scheme。 它不起作用,因为我得到相同的警告。 我能做些什么来解决这个警告? 请参阅下面的代码: func longPressedView(gestureRecognizer: UIGestureRecognizer){ /*Get cell info from where user tapped*/ if (gestureRecognizer.state == UIGestureRecognizerState.Ended) { var tapLocation: CGPoint = gestureRecognizer.locationInView(self.tableView) var tappedIndexPath: NSIndexPath? = self.tableView.indexPathForRowAtPoint(tapLocation) if (tappedIndexPath != nil) { var […]

如何在UIAlertController中添加button在IOS 9中

我们如何在iOS 9中使用UIAlertView以及如何在UIAlertController添加button UIAlertController * alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"Message"preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* yesButton = [UIAlertAction actionWithTitle:@"Yes, please" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { **//What we write here????????** }]; UIAlertAction* noButton = [UIAlertAction actionWithTitle:@"No, thanks" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { **//What we write here????????** }]; [alert addAction:yesButton]; [alert addAction:noButton]; [self presentViewController:alert animated:YES completion:nil];

UIAlertView for iOS 9的替代scheme?

UAlertView在iOS 9及更高版本中已弃用。 什么是替代? UIAlertView *new = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your InApp Purchases were successfully restored" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [new show];

UIAlertController崩溃(iPad)

我正在使用Xcode 6开发iOS应用程序。 当我使用UIAlertController ,它可以在iPhone 6模拟器上运行,但在iPad模拟器上崩溃。 我的问题,同时点击“分享”,然后它可能会坠毁。 我怎么能解决它? 这是我的代码: override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject] { var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in let shareMenu = UIAlertController(title: nil, message: "Share using", preferredStyle: .ActionSheet) let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil) let facebookAction = UIAlertAction(title: […]

如何解除UIAlertController和键盘同时?

我用UIAlertController创build了一个registry单,并使用方法addTextFieldWithConfigurationHandler添加一个文本字段。 但是有一个小问题。 当窗体出现时,键盘和模态以平滑的animation出现。 closures窗体时,模式首先消失, 然后键盘消失。 这使得键盘突然下降。 我怎样才能使模式和键盘优雅地消失? lazy var alertController: UIAlertController = { [weak self] in let alert = UIAlertController(title: "Alert", message: "This is a demo alert", preferredStyle: .Alert) alert.addTextFieldWithConfigurationHandler { textField in textField.delegate = self } alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) return alert }() @IBAction func alert() { presentViewController(alertController, animated: true, completion: nil) […]

在iOS 9.0中,“UIAlertView”已被弃用。 相反,使用UIAlertController和UIAlertControllerStyleAlert的preferredStyle

我已经看到了更多的答案,但没有什么帮助。这是我的老警戒和行动 override func viewWillAppear(animated: Bool) { if Reachability.isConnectedToNetwork() == true { print("internet connection ok") } else { print("internet not ok") let alertView: UIAlertView = UIAlertView(title: "Alert ", message: "connect to internet", delegate: self, cancelButtonTitle: "settings", otherButtonTitles: "cancel") alertView.show() return } } func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) { if buttonIndex == 0 { //This will […]