iphone - uibutton image doesnt change when cell gets highlighted -


I have a custom UIbutton in each cell of my table view, it uses the Favs of Star button used in UIbutton Gmail, etc. Works like functionality. Whenever I click on that button, the appropriate item is added to the favs list and the image of the button is turned into a bright star image. After clicking on it again, that item is removed from the favs list and an empty star is used as its image.

I am experiencing the problem here is that when I select the cell, it always shows an empty image towards the button and not the highlighted star image.

Note that if the separator style of Tableview does not have any set, then this problem has been solved. But I want separator style.

If you can plz help

Used this code to change button image in normal and selected state. If you want to add a favorite list, you need to get the button index value.

  - (UITableViewCell *) Table view: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {customBtn = [UIButton button with type: UIButtonTypeCustom]; CustomBtn.frame = CGRectMake (292, 8.0, 30, 28); UIImage * Like image of image = [UIImage imageNamed: @ "Star Off Page"]; [Custombtn setbackground image: Impression Image for Choice: UICOntralStateAnternal]; [CustomBtn addTarget: Self-action: @Selector (addToFavouriteClicked1) for control events: UIControlEventTouchUpInside]; CustomBtn.tag = indexPath.row; [Add Cell.contentViewSubwayview: customBtn]; } - (zero) addToFavouriteClicked1: (ID) sender {UIImage * like selectImg = [UIImage imageNamed: @ "star on.png"]; UIImage * likeImg = [UIImage image named: @ "Star of page"]; If ([sender has been selected]) {[Sender Setizes: State for IMG: UIControllstat normal]; [Sender set selected: no]; } Other {[Sender set image: IMEg selected for choice forState: UIControlStateSelected]; [Sender set selected: yes]; }}    

Comments