1

我有一个按钮,它从 uitableViewCell 上的(隐藏->未隐藏)动画出来。

在tableViewCell中,在同一矩形位置有一个imageview和一个按钮,当用户从tableview中选择一个tableviewcell时,imageView动画隐藏,按钮动画显示。两个视图(imageView&button)从xib文件加载. 我已经向按钮添加了一个动作并将其与 IBAction 方法链接。

我的问题:当用户触摸按钮时,操作方法没有被调用,为什么?

[UIView beginAnimations:cell.id context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(focusCellFinished:finished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell.containerView cache:YES];
cell.imagePhoto.hidden = true;
cell.playButton.hidden = false;
[UIView commitAnimations];

当用户选择一个按钮时, tableView:didSelectRowAtIndexPath: 将被调用,我不需要那个,我只想调用按钮方法。

顺便说一句,我知道并尝试如果只是添加一个正常的按钮而没有动画消失,它可以添加一个目标动作并成功调用。

任何答案和意见将不胜感激,谢谢。

4

1 回答 1

0

试试这样

[UIView beginAnimations:cell.id context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(focusCellFinished:finished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell.containerView cache:YES];
cell.imagePhoto.transform =CGAffineTransformMakeTranslation (-100,30);
cell.playButton.transform =CGAffineTransformMakeTranslation (100,30);
[UIView commitAnimations];

这里CGAffineTransformMakeTranslation (x,y);根据你的框架位置改变值

于 2012-11-23T04:21:38.987 回答