UIAlertController : UICollectionViewFlowLayout is not defined warning every time I try to bringup a UIAlertcontroller
Tag : ios , By : user183526
Date : October 29 2020, 04:46 AM
I wish this helpful for you I am using a UIAlertController for taking user input and updating a table cell. Everytime when I try to create a alert, I get this following warning in console , You need to call alertcontroller.view.setNeedsLayout()
self.presentViewController(alertController, animated: true, completion: nil)
|
UIAlertController Giving error? Please Give the code for UIAlertController with Array of Strings As Buttons in Swift
Tag : ios , By : Jason Jennings
Date : March 29 2020, 07:55 AM
this one helps. First of all I going to explain you why this happen, you can see if you touch any of your buttons always the output result of the call of NSLog("%@",String(i)) is plLists.count - 1, this is because you're trying to set always the index of the for statement inside the closure of the actions you're adding. The variable is outside the scope of the closure. The main problem is that always the reference retained inside the closure in your case is the last index of the array, because as you said is increased and finally when it finish is assigned the value. func presentAction() {
let alertA = UIAlertController(title: "PlayLists", message: "Select From PlayLists Below", preferredStyle: .ActionSheet)
let action = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
let plLists = ["List1", "List2", "List3", "List4"]
for(var i = 0; i < plLists.count; i++) {
alertA.addAction(UIAlertAction(title: plLists[i], style: .Default, handler: self.handlerForAction))
}
alertA.addAction(action)
self.presentViewController(alertA, animated: true, completion: nil)
}
func handlerForAction(action: UIAlertAction) {
print(action.title!)
}
|
UIBarButtonItem loses custom appearance attributes when UIAlertController is presented
Tag : ios , By : user165781
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have a UIBarButtonItem in a UINavigationBar that has some custom appearance attributes (custom font, color). It appears normally most places throughout the app. , I reset the style after presenting the ActionSheet UIAlertController *alertVC = ...
[self presentViewController:alertVC animated:YES completion:^{
[self.navigationItem.leftBarButtonItem setDefaultAppearanceForSpecificItem];
[self.navigationItem.rightBarButtonItem setDefaultAppearanceForSpecificItem];
}];
[self setTitleTextAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:14],
NSForegroundColorAttributeName: [UIColor VKBlueColor]
}
forState:UIControlStateNormal];
|
How to get access to button placed on UIAlertController from handler of UITextField placed on UIAlertController?
Tag : ios , By : SpittingCAML
Date : March 29 2020, 07:55 AM
wish of those help Why don't you make an attribute of the UIAlertAction? I've changed your code: class TVC_ProgramsList: UITableViewController {
var enterNameAC = UIAlertController()
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
@IBAction func addpush(sender: UIBarButtonItem) {
addProgram()
}
func addProgram() {
enterNameAC = UIAlertController(title: "Adding program", message: "Enter program name", preferredStyle: UIAlertControllerStyle.Alert)
enterNameAC.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
enterNameAC.addAction(self.okAction)
enterNameAC.addTextFieldWithConfigurationHandler { (textField) -> Void in
textField.placeholder = "Program name"
textField.addTarget(self, action: #selector(TVC_ProgramsList.enterProgramNameAC_editingTextField), forControlEvents: UIControlEvents.AllEditingEvents)
}
self.presentViewController(enterNameAC, animated: true, completion: nil)
}
func enterProgramNameAC_editingTextField() {
let programNameString = enterNameAC.textFields![0].text!
// use okAction here
self.okAction.enabled = programNameString.characters.count > 0
}
}
|
-ms-appearance, -0-appearance, and appearance showing up as error in editor.
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The five main browsers (Edge, Chrome, Firefox, Safari & Opera) use a mix of -moz-appearance and -webkit-appearance. It is not supported in IE. So what your editor is telling you here is not that they are necessarily wrong, just there is no point having them. For some reason Edge uses -webkit-appearance instead of -ms-appearance -webkit-appearance: none;
-moz-appearance: none;
appearance: none;
|