标签: uialertcontroller

UIAertField中的UITextField(border,backgroundColor)

这是一个截图UIAlertController.我只是在玩自定义字体和textfield属性,但我无法完成以下任务:

  • 明确的背景 UITextField
  • 没有丑陋的边框(黑匣子)如下图所示

在此输入图像描述

当我更深入地研究代码和iOS运行时标题时,我能够修改边框和背景颜色,但上述问题仍然存在,因为这些属性属于容器UITextView.改变背景clearColor并没有帮助.

有没有人玩过这个?不确定我是否会将这些丑陋的文本字段用于生产我的应用程序.

编辑(5月13日,15日)以下答案由Rory McKinnel测试iOS 8 - 8.3并且工作得很好.结果如下:

在此输入图像描述

uitextfield ios uialertcontroller

12
推荐指数
2
解决办法
6377
查看次数

如何将进度条添加到UIAlertController?

我想在swift iOS 8 UIAlertController中添加进度条.这可能吗?有没有办法继承UIAlertController并添加progres栏并连接一些委托函数?

谢谢

ios progress-bar swift uialertcontroller

12
推荐指数
2
解决办法
1万
查看次数

UIAlertController按钮位置不一致

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"hello" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *ok     = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:hander]
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:hander]

[alertController addAction:ok];
[alertController addAction:cancel]; 
Run Code Online (Sandbox Code Playgroud)

警报显示:
iOS 8.1 iPod touch: [确定] [取消]
iOS 8.3 iPhone 6 Plus: [取消] [确定]

为什么按钮的位置与iPod和iPhone不同?

objective-c ios uialertcontroller uialertaction

11
推荐指数
1
解决办法
2492
查看次数

如何在UIAlertController中添加按钮在IOS 9中

我们如何UIAlertView在iOS 9中使用以及如何添加按钮UIAlertController

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];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uialertcontroller

11
推荐指数
2
解决办法
3万
查看次数

UIAlertController从UIBarButtonItem呈现,旋转后位置错误

我有UIToolBar一些按钮.我目前UIAlertController使用UIAlertControllerStyleActionSheet该按钮的演讲风格.它显示正确,但是当我旋转设备时,此操作表有错误的位置.

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction* destructive = [UIAlertAction actionWithTitle:destructiveTitle style:UIAlertActionStyleDestructive handler:someHandler];
[alertController addAction:destructive];

[alertController setModalPresentationStyle:UIModalPresentationPopover];
alertController.modalInPopover = YES;

alertController.popoverPresentationController.barButtonItem = barButton;

alertController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;

alertController.popoverPresentationController.delegate = self;

[self presentViewController:alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

还有一两件事在这里,popoverPresentationController:willRepositionPopoverToRectUIPopoverPresentationControllerDelegate没有叫我时,旋转装置.

这里出了什么问题,有什么建议吗?

提前致谢!

ios8 uialertcontroller

10
推荐指数
0
解决办法
3434
查看次数

dismissViewControllerAnimated在块中不起作用

我试着关闭UIViewController一个UIAlertController在显示.

这是我的代码:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title 
                                                                         message:msg
                                                                  preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Accept" 
                                                   style:UIAlertActionStyleDefault 
                                                 handler:^(UIAlertAction *action)
             {
                 [self dismissViewControllerAnimated:YES completion:nil];
             }];

[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:^{}];
Run Code Online (Sandbox Code Playgroud)

但是,self永远不会被解雇.谁知道如何解决这个问题?

UPDATE

如果我设置[self dismissViewControllerAnimated:YES completion:nil];在块之外,它可以工作.

iphone uiviewcontroller ios uialertcontroller

10
推荐指数
3
解决办法
1万
查看次数

无法在UIAlertController中选择按钮顺序

我的印象是,如果正常动作是破坏性动作,而另一个是UIAlertController中的取消动作,则破坏性动作应位于左侧,取消应位于右侧.

如果正常动作不具有破坏性,则正常动作应该在右侧,取消应该在左侧.

那就是说,我有以下几点:

var confirmLeaveAlert = UIAlertController(title: "Leave", message: "Are you sure you want to leave?", preferredStyle: .Alert)

let leaveAction = UIAlertAction(title: "Leave", style: .Destructive, handler: {
        (alert: UIAlertAction!) in

        //Handle leave

    }
)

let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)

confirmLeaveAlert.addAction(leaveAction)
confirmLeaveAlert.addAction(cancelAction)

self.presentViewController(confirmLeaveAlert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我的印象是,如果我添加第leaveAction一个,那么它cancelAction就是leaveAction左边的按钮.此情况并非如此.我尝试以相反的顺序添加按钮,这也导致按钮以相同的顺序添加.

我错了吗?有没有办法实现这个目标?

ios swift ios8 uialertcontroller

10
推荐指数
2
解决办法
2510
查看次数

仅在输入后启用UIAlertAction的UIAlertAction

我使用的是UIAlertController提出了一个对话UITextField和一个UIAlertAction按钮标记为"好".如何将多个字符(例如5个字符)输入到UITextField?中,如何禁用该按钮?

objective-c uitextfield ios uialertcontroller

10
推荐指数
3
解决办法
7821
查看次数

UIAlertController无法满足约束

我将我所有的UIActionSheetUIAlertViewUIAlertController

我的问题是当我尝试呈现UIAlertControllerActionSheet样式时。这是我的代码:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title"
                                                               message:@"My message"
                                                        preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:cancelAction];

UIAlertAction *OKAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:OKAction];

UIAlertAction *destroyAction = [UIAlertAction actionWithTitle:@"Destroy" style:UIAlertActionStyleDestructive handler:nil];
[alert addAction:destroyAction];

UIPopoverPresentationController *popPresenter = [alert popoverPresentationController];
popPresenter.sourceView = self.view;
popPresenter.sourceRect = self.view.bounds;

[self presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

这是错误:

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiactionsheet ios uialertcontroller

10
推荐指数
1
解决办法
3826
查看次数

如何在Swift中显示来自另一个类的警报?

我有一个主类,AddFriendsController它运行以下代码行:

ErrorReporting.showMessage("Error", msg: "Could not add student to storage.")
Run Code Online (Sandbox Code Playgroud)

然后我有这个ErrorReporting.swift文件:

进口基金会

class ErrorReporting {
    func showMessage(title: String, msg: String) {
        let alert = UIAlertController(title: title, message: msg, preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

显然,self不会在这里工作,并给我一个错误.我如何引用当前打开的视图控制器(即AddFriendsController在这种情况下),因为我希望在许多不同的swift文件中使用相同的方法?

谢谢.

uiviewcontroller swift uialertcontroller swift2.3

9
推荐指数
3
解决办法
5398
查看次数