I am making an app in Swift on which all elements are added programatically.
//This code is inside of viewDidLoad function
makeButtonWithName(button: answer0B, title: "0", font:
"HelveticaNeue", fontSize: resetHeight, frame: CGRect(x:width/2 -
viewWidth/2, y: firstViewY, width: viewWidth, height: viewHeight),
selector: #selector(self.answer0(_:)))
makeButtonWithName(button: answer1B, title: "0", font: "HelveticaNeue",
fontSize: resetHeight, frame: CGRect(x:width/2 - viewWidth/2, y:
secondViewY, width: viewWidth, height: viewHeight), selector:
#selector(self.answer1(_:)))
makeButtonWithName(button: answer2B, title: "0", font:
"HelveticaNeue", fontSize: resetHeight, frame: CGRect(x:width/2 -
viewWidth/2, y: thirdViewY, width: viewWidth, height: viewHeight),
selector: #selector(self.answer2(_:)))
makeButtonWithName(button: answer3B, title: "0", font:
"HelveticaNeue", fontSize: resetHeight, frame: CGRect(x:width/2 -
viewWidth/2, y: fourthViewY, width: viewWidth, height: viewHeight),
selector: #selector(self.answer3(_:)))
firstNumber = Int(arc4random_uniform(9))
secondNumber = Int(arc4random_uniform(9))
incorrectAnswer1 = Int(arc4random_uniform(18))
incorrectAnswer2 = Int(arc4random_uniform(18))
incorrectAnswer3 = Int(arc4random_uniform(18))
timer.invalidate()
seconds = 31
runTimer()
randomNumbers()
//End viewDidLoad function
func answer0(_ sender: UIButton!){
let a:Int? = Int((answer0B.titleLabel?.text)!)
if a == answerNumber{
correctIncorrectLabel.text = "Correct"
correctIncorrectLabel.textColor = UIColor.green
correctNumber += 1
}
else{
correctIncorrectLabel.text = "Incorrect"
correctIncorrectLabel.textColor = UIColor.red
}
randomNumbers()
}
func answer1(_ sender: UIButton!){
let b:Int? = Int((answer1B.titleLabel?.text)!)
if b == answerNumber{
correctIncorrectLabel.text = "Correct"
correctIncorrectLabel.textColor = UIColor.green
correctNumber += 1
}
else{
correctIncorrectLabel.text = "Incorrect"
correctIncorrectLabel.textColor = UIColor.red
}
randomNumbers()
}
func answer2(_ sender: UIButton!){
let c:Int? = Int((answer2B.titleLabel?.text)!)
if c == answerNumber{
correctIncorrectLabel.text = "Correct"
correctIncorrectLabel.textColor = UIColor.green
correctNumber += 1
}
else{
correctIncorrectLabel.text = "Incorrect"
correctIncorrectLabel.textColor = UIColor.red
}
randomNumbers()
}
func answer3(_ sender: UIButton!){
let d:Int? = Int((answer3B.titleLabel?.text)!)
if d == answerNumber{
correctIncorrectLabel.text = "Correct"
correctIncorrectLabel.textColor = UIColor.green
correctNumber += 1
}
else{
correctIncorrectLabel.text = "Incorrect"
correctIncorrectLabel.textColor = UIColor.red
}
randomNumbers()
printProblem()
}
func randomNumbers(){
firstNumber = Int(arc4random_uniform(9))
secondNumber = Int(arc4random_uniform(9))
answerNumber = firstNumber + secondNumber
printProblem()
randomButton = Int(arc4random_uniform(4))
incorrectAnswer1 = Int(arc4random_uniform(18))
incorrectAnswer2 = Int(arc4random_uniform(18))
incorrectAnswer3 = Int(arc4random_uniform(18))
showTextOnButton()
totalCorrect.text = "Total Correct: \(correctNumber)"
}
func showTextOnButton(){
if randomButton == 0 {
answer0B.setTitle("\(answerNumber)", for: .normal)
answer1B.setTitle("\(incorrectAnswer1)", for: .normal)
answer2B.setTitle("\(incorrectAnswer2)", for: .normal)
answer3B.setTitle("\(incorrectAnswer3)", for: .normal)
}
if randomButton == 1 {
answer1B.setTitle("\(answerNumber)", for: .normal)
answer0B.setTitle("\(incorrectAnswer1)", for: .normal)
answer2B.setTitle("\(incorrectAnswer2)", for: .normal)
answer3B.setTitle("\(incorrectAnswer3)", for: .normal)
}
if randomButton == 2 {
answer1B.setTitle("\(answerNumber)", for: .normal)
answer2B.setTitle("\(incorrectAnswer1)", for: .normal)
answer0B.setTitle("\(incorrectAnswer2)", for: .normal)
answer3B.setTitle("\(incorrectAnswer3)", for: .normal)
}
if randomButton == 3 {
answer1B.setTitle("\(answerNumber)", for: .normal)
answer2B.setTitle("\(incorrectAnswer1)", for: .normal)
answer3B.setTitle("\(incorrectAnswer2)", for: .normal)
answer0B.setTitle("\(incorrectAnswer3)", for: .normal)
}
}
func printProblem(){
questionLabel.text = "\(firstNumber) + \(secondNumber)"
}
func makeButtonWithName(button: UIButton,title: String, font: String, fontSize: Int, frame: CGRect, selector: Selector) {
let button = UIButton(type: UIButtonType.custom)
button.setTitle(title, for: .normal)
button.frame = frame
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = UIFont(name: font, size: CGFloat(fontSize))
button.addTarget(self, action: selector, for: .touchUpInside)
self.view.addSubview(button)
}
These 4 buttons have text. When you click each of these, text on the buttons is not changing. The functions are using set title to update the text on the buttons, but for every run of the app the buttons do their function but the text on them remains at 0.
Okay... so many codes. So basically, to change the button.text, use
button.setTitle("new text", for: .normal)
Also, when user clicks on the button,first thing you maybe want to disable it by:
button.isEnable = false
Then after click action, enable it again
button.isEnable = true
This is because it may cause unexpected error when user intentionally/unintentionally multi click on that button.
Related
I just created a UIButton and I want to do some action when I click on it i don't know how to do it , here is my way to just create uibutton only !!!:
lazy var test: UIButton = {
let test = UIButton()
test.translatesAutoresizingMaskIntoConstraints = false
test.setTitle("See More Answers", for: .normal)
test.setTitleColor(.systemBlue, for: .normal)
return seeMoreBtn
}()
The modern way is to add the action as a UIAction.
lazy var test: UIButton = {
let test = UIButton()
test.translatesAutoresizingMaskIntoConstraints = false
test.setTitle("See More Answers", for: .normal)
test.setTitleColor(.systemBlue, for: .normal)
let action = UIAction { action in
print("howdy!")
}
test.addAction(action, for: .touchUpInside)
return test
}()
Nicer syntax can be achieved through an extension, as I demonstrate here.
lazy var test: UIButton = {
let test = UIButton()
test.translatesAutoresizingMaskIntoConstraints = false
test.setTitle("See More Answers", for: .normal)
test.setTitleColor(.systemBlue, for: .normal)
test.addTarget(self, action: #selector(self.buttonPressedAction), for: .touchUpInside) // add target
return seeMoreBtn
}()
#objc func buttonPressedAction() {
//This function will get called when u press the button.
//include here what u want to do.
}
#objc func buttonAction() {
print("Button Tapped")
}
test.addTarget(self, action: #selector(buttonAction(_:)), for: .touchUpInside)
I have given the example for create the custom button and the custom label and set constraint in coding. The below code also contains the programmatically button action.
import UIKit
class ViewController: UIViewController {
let button = UIButton(frame: CGRect(x: 100,y: 400,width: 200,height: 60))
var label = UILabel(frame: CGRect(x: 100, y: 200, width: 200, height: 60))
var count : Int = 0
override func viewDidLoad() {
super.viewDidLoad()
button.setTitle("Click Button",for: .normal)
button.backgroundColor = UIColor.blue
button.setTitleColor(.white, for: .normal)
button.addTarget(self,action: #selector(buttonAction),for: .touchUpInside)
label.font = .systemFont(ofSize: 50)
label.backgroundColor = UIColor.gray
label.textAlignment = .center
self.view.addSubview(button)
self.view.addSubview(label)
}
#objc
func buttonAction() {
self.count += 1
self.label.text = "\(count)"
}
}
Output :-
Value of label increases when the button is click.
I have a custom UIView class called SortView with two radio buttons and neither of their respective selector functions are being called when I click on them. I have added an instance of the SortView class to a parent class with view.addView(). Here is my custom class:
class SortView: UIView {
// MARK: - Properties
lazy var driverSortRadioButton: UIButton = {
let button = UIButton(type: .system)
button.setImage(UIImage(named: "Radio Button - Unselected"), for: .normal)
button.setDimensions(height: 25, width: 25)
button.backgroundColor = .clear
button.contentMode = .scaleAspectFill
button.addTarget(self, action: #selector(handleDriverSortRadioButton), for: .touchUpInside)
return button
}()
lazy var pickupTimeSortRadioButton: UIButton = {
let button = UIButton(type: .system)
button.setImage(UIImage(named: "Radio Button - Unselected"), for: .normal)
button.setDimensions(height: 25, width: 25)
button.backgroundColor = .clear
button.contentMode = .scaleAspectFill
button.addTarget(self, action: #selector(handlePickupTimeSortRadioButton), for: .touchUpInside)
return button
}()
private let driverSortTitleLabel: UILabel = {
let label = UILabel()
label.text = "Sort by driver:"
label.textAlignment = .left
label.textColor = .white
label.font = UIFont(name: "AvenirNext-DemiBold", size: 18)
label.backgroundColor = .clear
return label
}()
private let pickupTimeSortTitleLabel: UILabel = {
let label = UILabel()
label.text = "Sort by pickup time:"
label.textAlignment = .left
label.textColor = .white
label.font = UIFont(name: "AvenirNext-DemiBold", size: 18)
label.backgroundColor = .clear
return label
}()
private let driverSortTextField: UITextField = {
let tf = UITextField()
tf.textColor = .black
tf.textAlignment = .center
tf.placeholder = "Louise"
tf.font = UIFont(name: "AvenirNext-DemiBold", size: 15)
tf.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
tf.setWidth(width: 150)
tf.layer.cornerRadius = 5
return tf
}()
private let pickupTimeSortTextField: UITextField = {
let tf = UITextField()
tf.textColor = .black
tf.textAlignment = .center
tf.placeholder = "2:00pm"
tf.font = UIFont(name: "AvenirNext-DemiBold", size: 15)
tf.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
tf.setWidth(width: 150)
tf.layer.cornerRadius = 5
return tf
}()
private enum radioButtonStates {
case driver
case pickupTime
}
private var radioButtonState = radioButtonStates.driver
// MARK: - Lifecycle
override init(frame: CGRect) {
super.init(frame: frame)
configureUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Selectors
#objc func handleDriverSortRadioButton() {
print("DEBUG: driver sort radio button clicked")
if radioButtonState != .driver {
pickupTimeSortRadioButton.setImage(UIImage(named: "Radio Button - Unselected"), for: .normal)
pickupTimeSortTextField.isEnabled = false
pickupTimeSortTextField.text = ""
radioButtonState = .driver
driverSortRadioButton.setImage(UIImage(named: "Radio Button - Selected"), for: .normal)
driverSortTextField.isEnabled = true
driverSortTextField.text = ""
}
}
#objc func handlePickupTimeSortRadioButton() {
print("DEBUG: pickup time sort radio button clicked")
if radioButtonState != .pickupTime {
driverSortRadioButton.setImage(UIImage(named: "Radio Button - Unselected"), for: .normal)
driverSortTextField.isEnabled = false
driverSortTextField.text = ""
radioButtonState = .pickupTime
pickupTimeSortRadioButton.setImage(UIImage(named: "Radio Button - Selected"), for: .normal)
pickupTimeSortTextField.isEnabled = true
pickupTimeSortTextField.text = ""
}
}
// MARK: - Helper Functions
private func configureUI() {
let driverSortStackView = UIStackView(arrangedSubviews: [driverSortRadioButton,
driverSortTitleLabel,
driverSortTextField])
driverSortStackView.axis = .horizontal
driverSortStackView.distribution = .fill
driverSortStackView.spacing = 5
let pickupTimeSortStackView = UIStackView(arrangedSubviews: [pickupTimeSortRadioButton,
pickupTimeSortTitleLabel,
pickupTimeSortTextField])
pickupTimeSortStackView.axis = .horizontal
pickupTimeSortStackView.distribution = .fill
pickupTimeSortStackView.spacing = 5
let stackView = UIStackView(arrangedSubviews:[driverSortStackView,
pickupTimeSortStackView])
stackView.axis = .vertical
stackView.distribution = .fill
stackView.spacing = 10
self.addSubview(stackView)
stackView.centerX(inView: self)
stackView.centerY(inView: self)
}
}
The functions which are not being called are handleDriverSortRadioButton and handlePickupTimeSortRadioButton. Here is instantiation:
private lazy var sortView = SortView()
and here is where I use it in my parent UIViewController class:
view.addSubview(sortView)
sortView.anchor(top:tableView.bottomAnchor,
left: view.leftAnchor,
right: view.rightAnchor,
paddingTop: 40,
paddingLeft: 32,
paddingRight: 32)
I'm going to guess that the problem is that a containing view (perhaps one of the stack views) has zero size. The result would be that its subviews are visible but not tappable.
Here is a debugging utility method you can use to track down this sort of thing:
extension UIView {
#objc func reportSuperviews(filtering:Bool = true) {
var currentSuper : UIView? = self.superview
print("reporting on \(self)\n")
while let ancestor = currentSuper {
let ok = ancestor.bounds.contains(ancestor.convert(self.frame, from: self.superview))
let report = "it is \(ok ? "inside" : "OUTSIDE") \(ancestor)\n"
if !filtering || !ok { print(report) }
currentSuper = ancestor.superview
}
}
}
Wait until your interface is all set up and the buttons are untappable, and then call that on one of the untappable buttons to get a report in the console.
Fixed it by adding with and height to the bottom stack view
sortView.anchor(top:tableView.bottomAnchor,
left: view.leftAnchor,
right: view.rightAnchor,
paddingTop: 40,
paddingLeft: 32,
paddingRight: 32,
width: view.frame.width,
height: 100)
I have an UIToolbar containing a UITextField. I want to show the toolbar above the keyboard and then display it again when I finish editing inside the textfield.
The issue is that it is working when selecting the textfield. However, the toolbar is disappearing from the view when hiding the keyboard.
What should be done to redisplay it again to my view?
My Swift code is:
Add UITextFieldDelegate
class ATCChatThreadViewController: MessagesViewController, MessagesDataSource, MessageInputBarDelegate, UITextFieldDelegate {
Create ToolBar is as below
func createToolbar(){
//Fixed space
let fixed = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.fixedSpace, target: self, action: nil)
fixed.width = 10
//Camera
//let img = UIImage(named: "camera-filled-icon")!.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
let img = UIImage.localImage("camera-filled-icon", template: true)
let iconSize = CGRect(origin: CGPoint.zero, size: CGSize(width: 30, height: 30))
let iconButton = UIButton(frame: iconSize)
iconButton.setTitleColor(uiConfig.primaryColor, for: .normal)
iconButton.setBackgroundImage(img, for: .normal)
let cameraItem = UIBarButtonItem(customView: iconButton)
cameraItem.tintColor = uiConfig.primaryColor
iconButton.addTarget(self, action: #selector(cameraButtonPressed), for: .touchUpInside)
//TextField true
textFieldChat = UITextField(frame: CGRectMake(0,0,(self.view.frame.size.width - 100) ,30))
textFieldChat.tintColor = uiConfig.primaryColor
textFieldChat.textColor = uiConfig.inputTextViewTextColor
textFieldChat.backgroundColor = uiConfig.inputTextViewBgColor
textFieldChat.layer.cornerRadius = 14.0
textFieldChat.layer.borderWidth = 0.0
textFieldChat.font = UIFont.systemFont(ofSize: 16.0)
textFieldChat.delegate = self
textFieldChat.attributedPlaceholder = NSAttributedString(string: "Start typing...".localized(), attributes: [NSAttributedString.Key.foregroundColor: uiConfig.inputPlaceholderTextColor])
let paddingView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 20))
textFieldChat.leftView = paddingView
textFieldChat.leftViewMode = .always
let textFieldButton = UIBarButtonItem(customView: textFieldChat)
//Fixed space
let fixedTwo = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.fixedSpace, target: self, action: nil)
fixedTwo.width = 10
//Send Button
let imgSend = UIImage.localImage("share-icon", template: true)
let iconSendSize = CGRect(origin: CGPoint.zero, size: CGSize(width: 30, height: 30))
let sendButton = UIButton(frame: iconSendSize)
sendButton.setTitleColor(uiConfig.primaryColor, for: .normal)
sendButton.setBackgroundImage(imgSend, for: .normal)
let sendItem = UIBarButtonItem(customView: sendButton)
sendItem
.tintColor = uiConfig.primaryColor
sendButton.addTarget(self, action: #selector(sendBtnPressedWith), for: .touchUpInside)
//Flexible Space
// let flexible = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil)
let flexible = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.fixedSpace, target: self, action: nil)
flexible.width = 10
//Toolbar
var bottomsafeAreaHeight: CGFloat?
if #available(iOS 11.0, *) {
bottomsafeAreaHeight = UIApplication.shared.windows.first{$0.isKeyWindow }?.safeAreaInsets.bottom ?? 0
} else {
// Fallback on earlier versions
bottomsafeAreaHeight = bottomLayoutGuide.length
bottomsafeAreaHeight = UIApplication.shared.keyWindow?.rootViewController?.bottomLayoutGuide.length ?? 0
}
toolbar = UIToolbar(frame: CGRectMake(0,(self.view.frame.size.height - 116 - (bottomsafeAreaHeight ?? 0)),view.frame.width,50))
toolbar.sizeToFit()
toolbar.barTintColor = UIColor.f5f5f5ColorBg()
toolbar.isTranslucent = false
toolbar.tintColor = uiConfig.primaryColor
toolbar.items = [fixed, cameraItem, fixed, textFieldButton,fixedTwo, sendItem,flexible]
view.addSubview(toolbar)
}
// MARK: - UITextFieldDelegate
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
textFieldChat.inputAccessoryView = toolbar
return true
}
func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
view.addSubview(toolbar)
self.toolbar.isHidden = false
return true
}
if only chat etxfield is using toolbar then replace line:
view.addSubview(toolbar)
with
textFieldChat.inputAccessoryView = toolbar
remove both methods textFieldShouldBeginEditing and textFieldShouldEndEditing
Newbie coder and learning Swift. I want the function to be applicable for both UIButtons and couldn't figure out how to make it happen for second one.
private lazy var boostButton: UIButton = {
let button = UIButton(type: .custom)
button.frame = CGRect(x: 10, y: 10, width: 80, height: 80)
button.setImage(UIImage(named: "simsek.png"), for: .normal)
button.imageView?.contentMode = .scaleAspectFit
button.contentHorizontalAlignment = .center
button.contentVerticalAlignment = .center
button.layer.cornerRadius = 0.5 * button.bounds.size.width
button.layer.masksToBounds = true
button.addTarget(self, action: #selector(touchDown), for: [.touchDown, .touchDragEnter])
button.addTarget(self, action: #selector(touchUp), for: [.touchUpInside, .touchDragExit, .touchCancel])
return button
}()
private lazy var informationButton: UIButton = {
let button = UIButton(type: .custom)
button.frame = CGRect(x: 120, y: 10, width: 35, height: 35)
button.setImage(UIImage(named: "yenigozlukgri.png"), for: .normal)
button.imageView?.contentMode = .scaleAspectFit
button.contentHorizontalAlignment = .center
button.contentVerticalAlignment = .center
button.layer.cornerRadius = 0.5 * button.bounds.size.width
button.layer.masksToBounds = true
button.addTarget(self, action: #selector(touchDown), for: [.touchDown, .touchDragEnter])
button.addTarget(self, action: #selector(touchUp), for: [.touchUpInside, .touchDragExit, .touchCancel])
return button
}()
These are my buttons. I don't use storyboard but I believe that's not essential for the solution.
#objc func touchDown() {
animator.stopAnimation(true)
boostButton.backgroundColor = .red
//highlightedColor
}
#objc func touchUp() {
animator = UIViewPropertyAnimator(duration: 0.5, curve: .easeOut, animations: {
self.boostButton.backgroundColor = .gray
})
animator.startAnimation()
}
What I want to do is, when one of the buttons are clicked, it should perform the animation. If I add informationButton like the boostButton to my functions, both of them perform the animation even though one button is clicked. It should work for just the clicked one. How can I fix it to be functional for even more buttons ?
Use the parameter
#objc func touchDown(_ sender:UIButton) {
animator.stopAnimation(true)
sender.backgroundColor = .red
//highlightedColor
}
#objc func touchUp(_ sender:UIButton) {
animator = UIViewPropertyAnimator(duration: 0.5, curve: .easeOut, animations: {
sender.backgroundColor = .gray
})
animator.startAnimation()
}
I want to create a tic tac toe style board with x's and o's. This first part works and changes the buttons code successfully.
func buttonAction(sender:UIButton!)
{
print("Button \(sender.tag) tapped")
var tag = sender.tag
print(sender.currentTitle!)
if sender.currentTitle! == "" {
sender.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
sender.setTitleColor(UIColor.redColor(), forState: .Normal)
sender.setTitle("X", forState: UIControlState.Normal)
} else if sender.currentTitle! == "X" {
sender.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
sender.setTitleColor(UIColor.greenColor(), forState: .Normal)
sender.setTitle("O", forState: UIControlState.Normal)
}else if sender.currentTitle! == "O" {
sender.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
//sender.setTitleColor(UIColor.greenColor(), forState: .Normal)
sender.setTitle("", forState: UIControlState.Normal)
}
}
This gives me the right button but no access to the title already in it.
#IBAction func deleteAnswers(sender: UIBarButtonItem) {
var totalBoxes = getTotalNumberOfBoxesInGrid()
var tag = Int()
for tag = 1; tag <= totalBoxes; tag++ {
let button = self.view.viewWithTag(tag) as? UIButton
button!.setTitle("", forState: UIControlState.Normal)
}
}
In fact in the second section changing the empty string "" (no title) to a letter, say "P" simply prints a "P" over the existing title. How do I get access the the original title?
I woke with this solution in my head and it works. However it is a solution and not strictly the answer to the question: i.e. how do I get access to a button title set up with send.setTitle. When the "sender" is only used to get a tag# and button titles are set up as I set them up below, delete and other functions needed to access the information work.
func buttonAction(sender:UIButton!)
{
print("Button \(sender.tag) tapped")
var tag = sender.tag
print(sender.currentTitle!)
if var button = self.view.viewWithTag(tag) as? UIButton {
if button.currentTitle! == "" {
button.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
button.setTitleColor(UIColor.redColor(), forState: .Normal)
button.setTitle("X", forState: UIControlState.Normal)
myUserValuesDictionary[globalAppD.newPuzzle.name]![tag] = 1
} else if button.currentTitle! == "X" {
button.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
button.setTitleColor(UIColor.greenColor(), forState: .Normal)
button.setTitle("O", forState: UIControlState.Normal)
myUserValuesDictionary[globalAppD.newPuzzle.name]![tag] = 2
}else if button.currentTitle! == "O" {
button.titleLabel!.font = UIFont(name: "chalkduster", size: fontSizeTag)
//button.setTitleColor(UIColor.greenColor(), forState: .Normal)
button.setTitle("", forState: UIControlState.Normal)
myUserValuesDictionary[globalAppD.newPuzzle.name]![tag] = 0
}
}
}