所以我注意到在iPad上的iOS8 beta 3(更新:仍然发生在iOS 11.2中),当尝试从a的委托方法中呈现视图控制器时UIActionSheet,"没有"发生并且日志消息输出到调试控制台,说明在转换警报控制器时尝试演示:
Warning: Attempt to present <UIViewController: 0x...> on <ViewController: 0x...> which is already presenting <UIAlertController: 0x...>
Run Code Online (Sandbox Code Playgroud) 我正在使用Swift编写应用程序,我需要显示警报.该应用必须兼容iOS 7和iOS 8.由于UIAlertView已被替换UIAlertController,如何在UIAlertController不检查系统版本的情况下检查是否可用?我听说Apple建议我们不要检查设备的系统版本,以确定API的可用性.
这就是我在iOS 8中使用的,但是在iOS 7上用" dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction" 崩溃了:
let alert = UIAlertController(title: "Error", message: message, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alert.addAction(cancelAction)
presentViewController(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
如果我使用UIAlertView for iOS 8,我收到此警告: Warning: Attempt to dismiss from view controller <_UIAlertShimPresentingViewController: 0x7bf72d60> while a presentation or dismiss is in progress!
UIAlertController有两个按钮,样式设置为:
UIAlertActionStyle.Cancel
UIAlertActionStyle.Default
Run Code Online (Sandbox Code Playgroud)
在iOS 8.2中,"取消"按钮为非粗体,"默认"为粗体.在iOS 8.3中,它们已经转换
您可以看到Apple自己的应用程序,例如,设置>邮件>添加帐户> iCloud>输入无效数据,然后在8.3上显示如下:
不支持的Apple ID
了解更多(粗体)确定(非粗体)
而8.2则是另一种方式.
任何解决方法,使它再次像8.2.为什么会改变?
我已经看过UIAlertControllers的几个屏幕截图,在行的左边有一个图像,但我没有在文档中看到它.视觉的一个例子是
这是我现在为我的控制器提供的代码:
UIAlertController * view = [UIAlertController
alertControllerWithTitle:@"My Title"
message:@"Select you Choice"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
}];
[view addAction:ok];
[self presentViewController:view animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud) 我正在维护一个基于SDK 6.0的旧iOS项目.
这个项目的方法称为
-(void) showComboBox:(UIView*)view:withOptions:(NSDictionary*)options
用于显示组合框.为了实现这一目标,它使用了UIActionSheet,这在iOS8上已弃用.
我的解决方案是这样的:
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8) {
UIAlertController* alertController = [UIAlertController
alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* item = [UIAlertAction actionWithTitle:@"item"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
//do something here
//inform the selection to the WebView
...
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:item];
[alertController addAction:cancelAction];
//I am not sure whether it's the right way
if ([view.nextResponder isKindOfClass:UIViewController.class]) {
UIViewController* vc = (UIViewController*)view.nextResponder;
[vc presentViewController:alertController animated:YES completion:nil]; …Run Code Online (Sandbox Code Playgroud) 我增加了UITextField一个UIAlertController,这似乎为AlertView.在解雇之前UIAlertController,我想验证输入UITextField.基于验证,我想解雇UIAlertController或不解雇.但我不知道如何防止UIAlertController按下按钮时的解除动作.有没有人解决这个问题或任何想法从哪里开始?我去谷歌但没有运气:/谢谢!
我有一个UIAlertController,当他们在TouchID屏幕上选择"输入密码"时会提示用户.如何在屏幕上显示后恢复用户的输入?
let passwordPrompt = UIAlertController(title: "Enter Password", message: "You have selected to enter your passwod.", preferredStyle: UIAlertControllerStyle.Alert)
passwordPrompt.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil))
passwordPrompt.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
passwordPrompt.addTextFieldWithConfigurationHandler({(textField: UITextField!) in
textField.placeholder = "Password"
textField.secureTextEntry = true
})
presentViewController(passwordPrompt, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我知道OK按钮可能应该有一个处理程序,但是现在这段代码并没有真正做任何事情,但我想通过println显示文本字段的输出.这对我来说真的只是一个测试应用程序,可以学习Swift和一些新的API.
在尝试从popover显示UIActionSheet时,是否有人收到此消息?
您的应用程序提供了样式UIAlertControllerStyleActionSheet的UIAlertController().具有此样式的UIAlertController的modalPresentationStyle是UIModalPresentationPopover.您必须通过警报控制器的popoverPresentationController为此弹出窗口提供位置信息.您必须提供sourceView和sourceRect或barButtonItem.如果在显示警报控制器时未知此信息,则可以在UIPopoverPresentationControllerDelegate方法-prepareForPopoverPresentation中提供该信息.
在GM之前,我使用了一些解决方法将UIActionSheet转换为UIAlertController,这很好用.然而,似乎Apple试图解决UIActionSheet问题,我不想使用我的解决方法 - 但似乎我别无选择......
uiactionsheet uipopovercontroller ios ios8 uialertcontroller
我想在ios 8的警报视图中添加文本输入.我知道它已经完成,UIAlertController但没有任何想法.怎么做 ?
当使用a时UIAlertController,如果我想要呈现UIActionSheet空标题和空消息,则预期放置标题和/或消息的帧仍然存在.
如何更改此设置以便我只显示以下ActionSheet内容:
设置
退出
取消?
谢谢!
