像UITableViewCell中的iTunes商店一样重新创建歌曲预览

时间:2014-06-12 04:05:26

标签: ios xcode uitableview itunes

所以我几乎就在那里,我选择了艺术品并且播放了这首歌,我唯一的问题就是当我在另一个单元格中选择不同的歌曲时,我可以&#39 ; t取消选择当前歌曲并将其翻转回正常状态..我已经制作了一个自定义单元格,其中包含一个按钮,这是该按钮的操作:

-(NSIndexPath*)GetIndexPathFromSender:(id)sender{

if(!sender) { return nil; }

if([sender isKindOfClass:[UITableViewCell class]])
{
    UITableViewCell *cells = sender;
    return [self.tableView indexPathForCell:cells];
}

return [self GetIndexPathFromSender:((UIView*)[sender superview])];
}

-(IBAction) flipButton: (UIButton *)sender {

NSIndexPath *indexPath = [self GetIndexPathFromSender:sender];

SearchTableViewCell *cell2 = (SearchTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
[cell2.previewButton setSelected:NO];

if (sender.tag == 0) {
    sender.tag = 1;

    [cell2.previewButton setSelected:NO];
    [self.songPlayer pause];

    [UIView transitionWithView:cell2.artworkIMG duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                           cell2.artworkIMG.image = cell2.artworkIMG.image;
                       } completion:nil];

    [UIView transitionWithView:cell2.previewButton duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                           //[cell2.previewButton setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"white.png"]]];
                           [cell2.previewButton setSelected:YES];
                       } completion:nil];
    [self playselectedsong:indexPath];



} else {
    sender.tag = 0;

    [UIView transitionWithView:cell2.artworkIMG duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                           cell2.artworkIMG.image = cell2.artworkIMG.image;
                       } completion:nil];
    [UIView transitionWithView:cell2.previewButton duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                           [cell2.previewButton setSelected:NO];
                           //[cell2.previewButton setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"trans.png"]]];

                       } completion:nil];
    [self.songPlayer pause];

}





}

0 个答案:

没有答案