标签: uialertcontroller

在UIAlertController中禁用视差iOS

我正在开发的应用程序仅支持纵向模式.但是,在iOS8中,现在已弃用的UIAlertView可以进入横向并显示其他一些小问题.为了解决这个问题,我决定UIAlertController尝试一下.它有效,但我有一个新问题仍然有点烦人.警报不再进入景观,但确实以视差运动为特色.我在UIAlertController视图中添加了一个标签和一个图像,但那些不具有视差的东西,这意味着当用户移动手机时它看起来很奇怪.

我正在寻找两种选择,但我找不到如何做其中任何一种.
第一个解决方案是禁用视差,看看我们如何在应用程序的任何地方不支持它.
第二种解决方案是将视差支持添加到标签和图像.
无论如何,这是一段代码:

UIAlertController *welcomeAlertController = [UIAlertController
                                              alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Would you like to send %@ a message?", @"This message is displayed after adding a new message receiver. The %@ is the name of the receiver."), self.receiver.name]
                                              message:@"\n\n\n\n\n\n\n\n"
                                              preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction
                               actionWithTitle:NSLocalizedString(@"Skip", @"Skip: meaning user can skip a certain step.")
                               style:UIAlertActionStyleCancel
                               handler:^(UIAlertAction *action)
                               {
                                   [self cancelButtonPressed];
                               }];

UIAlertAction *okAction = [UIAlertAction
                           actionWithTitle:NSLocalizedString(@"Send", @"Send: meaning user can send information to somewhere.")
                           style:UIAlertActionStyleDefault
                           handler:^(UIAlertAction …
Run Code Online (Sandbox Code Playgroud)

ios parallax ios8 uialertcontroller

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

在swift中将图像添加到UIAlertController中

我想要一个带有图像的简单UIAlertController.我该怎么办?

let alertMessage = UIAlertController(title: "Service Unavailable", message: "Please retry later", preferredStyle: .Alert)
                alertMessage.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
                self.presentViewController(alertMessage, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

image swift uialertcontroller

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

取消当前显示的所有UIAlertControllers

有没有办法消除当前提供的所有UIAlertControllers?

这特别是因为在我的应用程序的任何位置和任何状态下,当按下推送通知时,我都需要进入某个ViewController。

uiwindow ios swift uialertcontroller

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

如何在UIAlertController中更改UIAlertAction的字体大小和颜色

https://www.safaribooksonline.com/library/view/ios-8-swift/9781491908969/images/ispc_0113.png

在上图中如何更改"完成","其他动作"的字体大小和颜色?以及如何更改"标题"和"消息"的字体大小和颜色?

谢谢.

iphone ios uialertcontroller uialertaction

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

Apple如何做这样的行动表?

前几天我正在探索新的Apple Music应用程序,并找到了一个相当奇特的行动表......

一个特殊的行动表

到现在为止,我不知道任何UIAlertControllerUIActionSheet可能有这样的分隔!想一想,他们是如何让那个顶部按钮看起来像一个桌面视图?

我已经倒在这两个UIActionSheet,UIAlertControllerUIAlertAction文件都没有成功.据我所知,Apple看起来并不善于对这些进行子类化,也不会弄乱视图层次结构.

那么我的问题如下:

  • 如何在自己的活动表上重现那些较厚的分隔物?
  • 如何重现顶部按钮,主动作体下方有图像和描述性文字?
  • 是否有任何当前的API提供此功能?

任何指导都将非常感谢.先感谢您.

uiactionsheet ios uialertcontroller

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

如何在swift2,iOS9中复制UIAlertController的消息?

我有一个简单的问题:如何让用户可以选择和复制UIAlertController的消息?

控制器启动如下:

let alertController = UIAlertController(title: "Hello World", message: "Copy Me!", preferredStyle: .Alert)
Run Code Online (Sandbox Code Playgroud)

并显示如下:

presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

ios swift uialertcontroller ios9 swift2

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

如何更改iOS中的UIAlertAction按钮颜色?

我有一个UIAlertController,我有一堆UIAlertAcion按钮.现在我需要显示一个带有其他颜色而不是相同颜色的按钮.

对于Ex

Button1的

BUTTON2

BUTTON3

Button1和button3应为蓝色

button2应为红色.

可能吗 ?怎么样?

只是扔你的想法......

我的代码:

UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Food Menu" message:@"Select the MenuItem" preferredStyle:UIAlertControllerStyleActionSheet];
for(int i= 0; i<[menus count];i++){

  UIAlertAction *action = [UIAlertAction actionWithTitle:[menu objectAtIndex:i] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
             [actionSheet dismissViewControllerAnimated:YES completion:nil];
             //do SomeWork

          }];

          if(i==currentIndex){
              //Put button Color Red
             }
           else{
             //put button color Blue
             }
          [actionSheet addAction:action];
       }

       UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction* action){
          [actionSheet dismissViewControllerAnimated:YES completion:nil];
       }];

       [actionSheet addAction:cancel];


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

objective-c ios uialertcontroller uialertaction

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

如何在UIAlertController上添加动态按钮?

我正在使用UIActionSheet转换我的代码以使用UIAlertController.

我使用UIActionSheet的方式是这样的:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Gender"
                                                         delegate:self
                                                cancelButtonTitle:nil
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:nil];
for (NSDictionary *genderInfo in self.genderList) {
    NSString *gender = [[genderInfo objectForKey:@"description"] capitalizedString];
    [actionSheet addButtonWithTitle:gender];
}
[actionSheet addButtonWithTitle:@"Cancel"];
Run Code Online (Sandbox Code Playgroud)

只需处理代理行动表方法中按下的按钮.

在将其转换为警报控制器时,我注意到每个警报操作都有一个处理程序.我想知道如何实现警报控制器以获得可以处理操作的动态按钮.

objective-c ios uialertcontroller

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

UIAlertController中的自定义视图

我想把一个自定义视图放在一个UIAlertController.我在调整自定义视图的大小时遇到​​了一些奇怪的问题.

我想自定义视图跨越的宽度UIAlertController,无论可能是什么.我正在使用CGRectGetWidth(alertController.view.bounds)获取警报控制器的宽度.但是,这似乎是返回整个视图的宽度.使用view.frame并没有什么区别.

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

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(alertController.view.bounds), 50)];
view.backgroundColor = [UIColor blueColor];

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

这产生了以下结果.我有同样的问题试图获得的X,Y宽度和高度属性UIAlertController.有没有人知道如何在不使用硬编码数字的情况下将此视图放在警报控制器的中间?

在此输入图像描述

custom-controls subview custom-view ios uialertcontroller

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

UIAlertController解除完成永远不会被调用

在以下代码中,当我的Web视图无法加载时,正如预期的那样,使用"重试"按钮正确显示警报.点击"重试"按钮时警报会消失,但永远不会调用完成.为什么是这样?

func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
    let alert = UIAlertController(title: "Network Error", message: "There was a error loading the page.", preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: "Retry", style: .default, handler: { _ in
        alert.dismiss(animated: true, completion: {
            self.webView.loadHTMLString("Reloaded", baseURL: nil)
        })
    }));

    self.present(alert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

swift uialertcontroller

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