有没有办法在Swift中立即更改UIBarButtonItem?

时间:2016-01-12 22:39:47

标签: ios swift

我添加了一个"最喜欢的图标" (顶部导航栏中的一颗心):

bash-3.2$ javac -version
javac 1.8.0_65
bash-3.2$ javac -source 1.7 -target 1.7 MyArrayList.java 
warning: [options] bootstrap class path not set in conjunction with -source 1.7
MyArrayList.java:7: error: name clash: sort(Comparator<E#1>) in MyArrayList and sort(Comparator<? super E#2>) in ArrayList have the same erasure, yet neither overrides the other
    public void sort(Comparator<E> c) {
                ^
  where E#1,E#2 are type-variables:
    E#1 extends Object declared in class MyArrayList
    E#2 extends Object declared in class ArrayList
1 error
1 warning

有没有办法确保它被点击后立即改变(破碎的心脏)?

我必须回到tableView并回到细节,然后我看到更新的图标。点击它确实是逻辑,但心脏没有更新。这些是我Dua Class中的功能。

var faveMeItem = UIBarButtonItem (title: dua.isFavorite() ? "❤️" : "", style: .Plain, target: self, action: "toggleFav")

1 个答案:

答案 0 :(得分:0)

func toggleFavorite() {
    if isFavorite() {
        removeFromFavorites()
    } else {
        addToFavorites()
    }
faveMeItem.title = dua.isFavorite() ? "❤️" : "" //Add this
}