我正在尝试使用Xcode 4.2故事板创建一些单元格,并使用Interface Builder创建自定义单元格。我创建的单元格很好,内部有一个按钮,当我按下按钮时,图像会发生变化,但它似乎不起作用。这是我的iPhone - UITableViewCell中的按钮不会更改图像
- (IBAction)sendToFavorites:(id)sender {
UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview];
int row = [feedTableView indexPathForCell:cell].row;
NSLog(@"\"%@\" is FAVORITED", [[_allEntries objectAtIndex:row] articleTitle]);
if ([[_allEntries objectAtIndex:row] isFavorited]) {
NSLog(@"Unfavorite");
[[_allEntries objectAtIndex:row] setFavorite:NO];
[[sender imageView] setImage:[UIImage imageNamed:@"StarEmpty"]];
} else {
NSLog(@"Favorite");
[[_allEntries objectAtIndex:row] setFavorite:YES];
[[sender imageView] setImage:[UIImage imageNamed:@"StarFilled"]];
}
}
任何帮助,将不胜感激。
你得到的日志(取消收藏/最喜欢的)? – sergio
是的,所有NSLogs都应该打印。 –
另外,在切换图像时,似乎只需要一秒钟就可以完成,但是会使用StarEmpty。我会因为在IB中将图像设置为StarEmpty吗? –