草庐IT

UIAlertcontroller

全部标签

ios - Swift - 强制用户在 UIAlertController 中输入(即不是空白输入)

我想在我的一个应用程序中查询用户的姓名。我想进行检查以确保用户输入了非空字符串,然后在输入无效时用错误消息重新提示用户。到目前为止,这就是我所拥有的:whilename==""{name=promptUserForName()}promptUserForName()方法是这样的:privatefuncpromptUserForName()->String{letalert=UIAlertController(title:"Enteryourname:",message:nil,preferredStyle:.Alert)//Presentsakeyboardforusertoenter

ios - UIAlertController 错误在 swift 模式呈现的 View Controller 中调用时

我有一个以模态方式呈现的ViewController,当我运行UIAlertController时,不断收到错误消息。我该如何解决这个问题。警报由检查文本字段是否为空的按钮触发。@IBActionfuncregisterAction(sender:AnyObject){if(userEmail.isEmpty){alertMessage("FieldsAreEmpty")}}funcalertMessage(userMessage:String){varmyAlert=UIAlertController(title:"Alert",message:userMessage,preferr

ios - 无法在 Swift 中的 UITableViewController 中呈现 UIAlertController

我有一个UIAlertController,我想在UITableViewController中显示它。但是,当我运行代码时,出现以下错误:Warning:Attempttopresentonwhoseviewisnotinthewindowhierarchy!我的代码似乎反射(reflect)了answer中的建议.我做错了什么?overridefuncviewDidLoad(){super.viewDidLoad()//Checkforforcetouchfeature,andaddforcetouch/previewingcapability.iftraitCollection.f

swift - 如何呈现带有文本字段的 UIAlertController,但该文本字段不能是第一响应者?

我想呈现一个带有文本字段的UIAlertController。这个完成了。但我不希望它成为第一响应者。有什么方法可以用文本字段呈现UIAlertController,但文本字段不应该是第一响应者?funcshowAlertData(data:String,atindexPath:IndexPath){lettitle=dataletalert=UIAlertController(title:renameDocumentString,message:renameDocumentMessageString,preferredStyle:UIAlertControllerStyle.aler

ios - 更改 UIAlertController 背景色

是的,我知道。您无法更改UIAlertController的外观。我不想更改UIAlertController本身的背景,我想更改View背景的色调。你知道它像透明的黑色吗?我想将该颜色更改为清除。我该怎么做? 最佳答案 对于swift3UIAlertController改变背景颜色。letalert=UIAlertController(title:"validate",message:"Checktheprocess",preferredStyle:.alert)letdismissAction=UIAlertAction(tit

swift - 如何更改 UIAlertController 中按钮的字体

我需要更改UIAlertController中按钮的字体,我使用了下面的代码,但我无法正常工作,因为当用户触摸UIAlertController的按钮时,字体将更改为默认字体。extensionUIAlertController{privatefuncchangeFont(view:UIView,font:UIFont){foriteminview.subviews{ifletcol=itemas?UICollectionView{forrowincol.subviews{changeFont(view:row,font:font)}}ifletlabel=itemas?UILabel

ios - 尝试呈现其 View 不在窗口层次结构中的 UIAlertController - Swift 错误

我正在尝试创建一个警报,这样当用户注册然后想重新登录时,如果密码错误,他们会收到警告,因为此时它只是执行segue并且尝试警报失败。我正在使用Firebase,因此在注册时输入到Firebase的密码应该是用户登录时使用的密码。importFoundationimportUIKitimportFirebaseclassSignInViewController:UIViewController,UITextFieldDelegate{@IBOutletweakvarEmailAddressTextField:UITextField!@IBOutletweakvarPasswordText

swift - 更改 UIAlertController 的标题字体大小

我正在尝试更改UIAlertController中的标题fontSize,但我无法管理如何将我的NSMutableAttributedString设置为title-属性。所以我一直在使用以下代码创建NSMutableAttributedString:lettitle=NSMutableAttributedString(string:user.fullName)letrange=NSRange(location:0,length:title.length)title.addAttribute(NSAttributedStringKey.font,value:UIFont.TextStyl

iOS 8 swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

上下文非常简单,有一个带有文本字段的UIViewcontroller,用于输入电话号码。文本字段处于使用键盘的编辑模式。输入数字后,用户可以点击显示警报Controller的按钮。由于警报以模态方式呈现,它覆盖了UIViewcontroller并移除了键盘,因此不再启用编辑。因此我的问题是,应该怎么做才能使键盘显示在警报后面? 最佳答案 这个解决方案有效letrootViewController:UIViewController=UIApplication.sharedApplication().windows[1].rootVie

ios - 在当前事件的 UIViewController 中呈现 UIAlertController

我有一个计时器,它会在完成时显示警报。此警报View应显示在用户当前所在的ViewController中。我的感觉是这可以比以下更有效地实现:我现在这样做的方式是为我的5个ViewController中的每一个提供一个通知观察者,以及一个创建和显示该警报的方法。有没有办法只设置一次警报,然后将其呈现在当前事件的ViewController中?这是我的代码://I'vegotthefollowingineachofmyviewcontrollers.//InviewDidLoad()overridefuncviewDidLoad(){super.viewDidLoad()NSNotifi