Gor*_*ilt 2 cocoa-touch uibutton ios swift
我使用UIButton作为标签在其标题中显示一些数字.每次调用该函数以重置此按钮的标题时,它都会闪烁.它不会影响功能但会损害用户体验.我想知道是否有办法阻止UIButton突然出现这种突出行为?
提前致谢!
编辑:以下是我只是调用委托方法updateDigits刷新按钮标题的代码.
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate, DigitsEntryViewDelegate {
@IBOutlet weak var tipField1: UIButton!
@IBOutlet weak var tipField2: UIButton!
var buttonsArray = [UIButton]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tipField1.tag = 0
self.tipField2.tag = 1
self.tipField1.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)
self.tipField2.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)
self.buttonsArray.append(self.tipField1)
self.buttonsArray.append(self.tipField2)
}
func inputFieldClicked(sender: UIButton) {
let anchor: UIView = sender
let viewControllerForPopover = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("DigitEnter") as! DigitsEntryViewController
// set popover API values
viewControllerForPopover.currentDigitsString = sender.currentTitle
viewControllerForPopover.tagNumber = sender.tag
viewControllerForPopover.delegate = self
viewControllerForPopover.preferredContentSize = CGSizeMake(240, 320)
let popover = UIPopoverController(contentViewController:viewControllerForPopover)
popover.presentPopoverFromRect(anchor.frame, inView: anchor.superview!, permittedArrowDirections: UIPopoverArrowDirection.Down, animated: false)
}
func updateDigits(returnedDigits: String, tagNumber: Int) {
self.buttonsArray[tagNumber].setTitle(returnedDigits, forState: UIControlState.Normal)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1022 次 |
| 最近记录: |