标签: uialertcontroller

没有模糊视图效果的 UIAlertController 操作表

我正在用于UIAlertController一些操作。

但我不太喜欢动作组视图中的模糊视图效果(请参见下面的屏幕截图)。

具有模糊视图的操作表

我正在尝试消除这种模糊效果。我在网上做了一些研究,但找不到任何UIAlertController可以消除这种模糊效果的 API。另外,根据他们的苹果文档:

UIAlertController 类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改。

我看到 Instagram 也消除了这种模糊的视图效果:

Instagram 的固定版本

我找到删除它的唯一方法是通过UIAlertController.

extension UIAlertController {
    @discardableResult private func findAndRemoveBlurEffect(currentView: UIView) -> Bool {
        for childView in currentView.subviews {
            if childView is UIVisualEffectView {
                childView.removeFromSuperview()
                return true
            } else if String(describing: type(of: childView.self)) == "_UIInterfaceActionGroupHeaderScrollView" {
                // One background view is broken, we need to make sure it's white.
                if let brokenBackgroundView = childView.superview {
                    // Set broken brackground view to a darker white …
Run Code Online (Sandbox Code Playgroud)

objective-c ios swift uialertcontroller uivisualeffectview

5
推荐指数
1
解决办法
1480
查看次数

将 SF 符号添加到 UIAlert 的标题中

我在将 SF 符号添加到标题时遇到问题。SF 符号与标题文本重叠有人可以帮助我吗

在此输入图像描述

func uialert(){

    let alert = UIAlertController(title: "New User Created", message: " A new user has been created.", preferredStyle: .alert)
    let imgTitle = UIImage(systemName: "checkmark.circle")
    let imgViewTitle = UIImageView(frame: CGRect(x: 120, y: 10, width: 30, height: 30))
    imgViewTitle.image = imgTitle
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
    alert.view.addSubview(imgViewTitle)
    self.present(alert, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

swift uialertcontroller ios13 sf-symbols

5
推荐指数
1
解决办法
1536
查看次数

UIAlertController的textfield委托不会被调用

我已经向UIAlertController添加了一个UITextField,但是shouldChangeCharactersInRange不会被触发.为什么?我设置了代表.

let alertController = UIAlertController(title: "", message: "xxx", preferredStyle: .Alert)

            self.presentViewController(alertController, animated:true, completion:nil)
            let textField = UITextField()
            textField.delegate = self
            alertController.addTextFieldWithConfigurationHandler(nil)
Run Code Online (Sandbox Code Playgroud)

代表团在同一个班级:

func textField(textField: UITextField!,
    shouldChangeCharactersInRange range: NSRange,
    replacementString string: String!) -> Bool {
Run Code Online (Sandbox Code Playgroud)

uitextfield uitextfielddelegate swift uialertcontroller

4
推荐指数
1
解决办法
3000
查看次数

UIAlertAction在其回调中解散UIAlertController

我正在尝试使用UIAlertControlleriOS 8中引入的新功能.除了UIAlertAction总是最终在其回调中解除警报控制器这一事实外,一切都很有效.以下是我的代码:

let alert = UIAlertController(title: "New Group", message: "Enter Group name", preferredStyle: UIAlertControllerStyle.Alert);
alert.addTextFieldWithConfigurationHandler({ [weak self] (nameField: UITextField!) in
    nameField.becomeFirstResponder();
    nameField.delegate = self;
    return;
})
alert.addAction(UIAlertAction(title: "Done", style: .Default, handler: { action in
    println("Done Entering");
}));
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil));
self.presentViewController(alert, animated: true, completion: nil);
Run Code Online (Sandbox Code Playgroud)

现在,当我单击"完成"按钮时,控件进入回调方法,然后警报被解除,即使我没有任何声明来解除警报.这种行为是默认的吗?如果是,我怎样才能确保在某些情况下警报停留在屏幕上(取决于我的条件)?我在这里错过了什么吗?

我真的很感激有关这方面的任何帮助.

swift ios8 uialertcontroller

4
推荐指数
1
解决办法
6850
查看次数

从自定义类调用presentViewController

我读了这篇文章这一个关于如何调用presentViewController形式的UIViewController子类之外.在我的例子中,自定义类是NSObject的子类.以下方法是唯一有效的方法(从我读过的例子):

UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我的问题:是否有一个更好的解决方案,不依赖于appDelegate(因为我知道这种方法在设计方面不是很整洁)......

ios swift uialertcontroller

4
推荐指数
1
解决办法
5619
查看次数

如何在UiView中显示AlertController

Swift的新手.下面的代码执行没有错误,但在控制台中它显示一条消息.这是一条错误消息以及如何修复它?是否需要在发送应用程序进行审核时修复.

谢谢

这是我的App结构:

VC(1)     -->  goto -->    VC(2)

在VC(1)中,我有:

  • BtnGo
  • UiLabelMsg
  • UITableView的

我创建了一个VC的链接(2):控制 - 拖动BtnGo到VC(2)

我将segue命名为:SegueToVC2

我想做什么:

我需要将一个字符串传递给VC2.在通过之前检查用户是否做出选择.

在PrepareForSegue中,

override func PrepareForSegue(segue:UIStoryboardSegue, sender: AnyObject!) {

    var strchk: String = UIlabelMsg.text!

    if strchk.isEmpty {

        var alert = UIAlertController(title: "Alert",message:" No Selection made",
           preferredStyle: UIAlertControllerStyle.Alert)

        alert.AddAction(UIAlertction(title: "OK",style:UIAlertActionStyle.Default,hanlder: nil))

        self.presentViewController(alert, animated: true, completion: nil ) 

    } else {

    if (segue.Identifier =="SegueToVC2") {

        var targetVC = segue.destinationViewControl as! VC2
        targetVC.strMsg = UILabelMsg.text
    }
}
Run Code Online (Sandbox Code Playgroud)

问题:

在控制台中,它显示了这个:

UIView:0x7fdfc25668c0; frame =(0,0,375,667); autoresize = w …

uiview ios swift uialertcontroller

4
推荐指数
1
解决办法
5124
查看次数

如何在UIAlertController中放置UIActivityIndi​​catorView?

我们正在离开MBProgressHUD,因为它在我们的应用程序中太麻烦了,并且没有阻止用户输入或提供取消按钮等功能.

那么,我试图在UIAlertController的中心实现Swipesight的如何显示活动指示器?,我遇到了指标的不正确定位:

一个<code>UIActivityIndicatorView</code>在<code>UIAlertController</code>白色矩形中保留空间</strong>,然后<strong>如何将其放在那里?</strong></p> </div>
        <p>
          <a href=objective-c uiactivityindicatorview ios uialertcontroller

4
推荐指数
1
解决办法
6920
查看次数

是否可以横向旋转UIAlertController(和Alert)?

我正在编辑一个应用程序,我在其中添加了一个新的UIViewController,用于在一个布局中配置多人游戏.

我为每个玩家添加了两个按钮(顶部按钮,机器人按钮).每个按钮在屏幕上生成一个警报(记住它是横向的),但问题是,玩家2看不到警报旋转,我的意思是,警报应该以他的方向显示在我面前.

有没有办法做到这一点?我想为播放器2旋转警报,不会看到警报的信息.

这里有我的警报代码:

@IBAction func ShowAlert(){
let message = "Test"
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)

let action = UIAlertAction(title: "OK", style: .Default, handler: nil)

    alert.addAction(action)

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

rotation ios swift uialertcontroller

4
推荐指数
1
解决办法
2314
查看次数

UIActionSheet/UIAlertController多行文本

这是我要编写的代码UIActionSheet.

actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"updateresponseforrecurring", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:
                   NSLocalizedString(@"updateresponseonlyforthis", nil),
                   NSLocalizedString(@"updateresponseforallactivities", nil),
                   nil];
    actionSheet.tag = 2;
    [actionSheet showInView:[UIApplication sharedApplication].keyWindow];  
Run Code Online (Sandbox Code Playgroud)

这就是我使用它:

在此输入图像描述

显然,第二种选择更长,因此尺寸变小以适应宽度.
但我希望所有选项都使用相同的字体大小,这样我就可以使用多行.也试过UIAlertController但不能设置多行文字.怎么做到这一点?

uiactionsheet ios uialertcontroller

4
推荐指数
1
解决办法
4402
查看次数

iOS - 默认情况下,选择器/处理程序是否在主队列上运行?

假设,我提出的UIAlertController,比方说myAlert,从主胎面.myAlert有一个动作,defaultAction.我想知道defaultAction默认情况下s处理程序是否在主队列上运行.换句话说,我想知道doStuff下面的代码里面是否有一些与UI相关的操作,我是否需要用主队列包装这些UI任务,或者保证在OS的主队列中运行?

UIAlertController* myAlert = [UIAlertController alertControllerWithTitle:@"My Alert"
                               message:@"This is an alert."
                               preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
   handler:^(UIAlertAction * action) {
      doStuff() // should I wrap doStuff in main queue, if doStuff has ui operations?
   }
];

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

multithreading handler thread-safety uialertcontroller

4
推荐指数
1
解决办法
1170
查看次数