remove unnecessary buttons
I have a question would like ask anyone expert in objective C and iPhone Dev.
I have a page used to add stuff to other page. Such as a have a page called artist. Open it will see artist history . Clicking it will lead to other pages carry the according contents. Inside each content has a button called add to favorite. Okey, now if the adding action made, this will add the entire artist to the favorite, and now if I go to favorite I see the icon for what I just added, click tha开发者_JAVA百科t I will be able to view the entire newly added content. But my problem is the add to favorite button is still there when I am already in the favorite page. I want the button to be disappeared when I go to that favorite page. Please could anyone help me in this. My code is too long so i cant post it. So base on what i describe, just give me some hints or whatsoever. I really appriciate your help.
Assuming that you use the standard ViewController approach:
In viewWillLoad
, set the property of your addToFavoritesButton according to the status of the artist that will be shown:
addToFavoritesButton.hidden = artistShown.isFavorite;
In the method that adds an artist to the favorites, also do this:
- (void) addToFavorites
{
...
artistShown.isFavorite = YES;
addToFavoritesButton.hidden = artistShown.isFavorite;
...
}
精彩评论