我使用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 …Run Code Online (Sandbox Code Playgroud) 当我将项目从Swift 1.2迁移到2.0时,我遇到了一个问题:我正在为我的UICollectionView使用自定义布局,这在Swift 1.2中运行良好.但是,在Swift 2.0中,Method does not override any method from its superclass在尝试覆盖layoutAttributesForElementsInRect自定义布局时会出现错误.
我试图删除override,现在错误变成了Method 'layoutAttributesForElementsInRect' with Objective-C selector 'layoutAttributesForElementsInRect:' conflicts with method 'layoutAttributesForElementsInRect' from superclass 'UICollectionViewLayout' with the same Objective-C selector.它让我无能为力.任何帮助,将不胜感激!
class CustomCollectionViewLayout: UICollectionViewLayout {
//...
override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
let attributes : NSMutableArray = NSMutableArray()
for section in self.itemAttributes {
attributes.addObjectsFromArray(
section.filteredArrayUsingPredicate(
NSPredicate(block: { (evaluatedObject, bindings) -> Bool in
return CGRectIntersectsRect(rect, evaluatedObject.frame)
})
)
)
}
return attributes as …Run Code Online (Sandbox Code Playgroud)