@IBAction func addToCart(sender: AnyObject) {
let itemObjectTitle = itemObject.valueForKey("itemDescription") as! String
let alertController = UIAlertController(title: "Add \(itemObjectTitle) to cart?", message: "", preferredStyle: .Alert)
let yesAction = UIAlertAction(title: "Yes", style: UIAlertActionStyle.Default) { (action) in
var badgeNumber = 0
self.navigationController!.tabBarItem.badgeValue == "\(badgeNumber++)"
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
alertController.addAction(yesAction)
alertController.addAction(cancelAction)
presentViewController(alertController, animated: true, completion: nil)
}
我需要选择"是"在每次按下时,在标签栏项目上增加徽章的警报,是否有人有这个问题?
答案 0 :(得分:2)
let yesAction = UIAlertAction(title: "Yes", style: .Default) { action in
// Your code to update the tab bar here
}
替代:
UIAlertAction(title: "Yes",
style: UIAlertActionStyle.Default,
handler: { // Code goes here
})