这是一个截图UIAlertController.我只是在玩自定义字体和textfield属性,但我无法完成以下任务:
UITextField
当我更深入地研究代码和iOS运行时标题时,我能够修改边框和背景颜色,但上述问题仍然存在,因为这些属性属于容器UITextView.改变背景clearColor并没有帮助.
有没有人玩过这个?不确定我是否会将这些丑陋的文本字段用于生产我的应用程序.
编辑(5月13日,15日)以下答案由Rory McKinnel测试iOS 8 - 8.3并且工作得很好.结果如下:

我想在swift iOS 8 UIAlertController中添加进度条.这可能吗?有没有办法继承UIAlertController并添加progres栏并连接一些委托函数?
谢谢
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不同?
我们如何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) 我有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:willRepositionPopoverToRect从UIPopoverPresentationControllerDelegate没有叫我时,旋转装置.
这里出了什么问题,有什么建议吗?
提前致谢!
我试着关闭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];在块之外,它可以工作.
我的印象是,如果正常动作是破坏性动作,而另一个是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左边的按钮.此情况并非如此.我尝试以相反的顺序添加按钮,这也导致按钮以相同的顺序添加.
我错了吗?有没有办法实现这个目标?
我使用的是UIAlertController提出了一个对话UITextField和一个UIAlertAction按钮标记为"好".如何将多个字符(例如5个字符)输入到UITextField?中,如何禁用该按钮?
我将我所有的UIActionSheet和UIAlertView带UIAlertController。
我的问题是当我尝试呈现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) 我有一个主类,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文件中使用相同的方法?
谢谢.