[英]ios 5 subview flip between two view in tableview cell
我有包含自定义单元格的tableview。 用户单击该行时,每个单元格都有要翻转的视图。 我成功地使其适用于此。 但是我要解决的问题是当用户单击另一行时,我想返回到上一个单元格的原始视图并翻转当前单击的行。
这是一些代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *selectedCell =
(CustomCell *)[self.AlbumViewTable cellForRowAtIndexPath:self.current_index];
//if other row is already flipped then make it back to original state.
if(otherRowIsFlipped){
selectedCell.defaultImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"defaultIndecator.jpg"]];
selectedCell.defaultImage = CGRectMake(0, 0, 43, 43);
[self flipView:selectedCell.flipViewContainer From:selectedCell.activity To:selectedCell.defaultImage];
}
CustomCell * new_row =
(CustomCell *)[self.AlbumViewTable cellForRowAtIndexPath:indexPath];
new_row.activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
new_row.activity.frame = CGRectMake(0, 0, 43, 43);
[new_row.activity startAnimating];
//this method is merely called UIView subroutine to flip between two view
[self flipView:new_row.flipViewContainer From:new_row.defaultImage To:new_row.activity];
[self.AlbumViewTable deselectRowAtIndexPath:indexPath animated:YES];
}
我能够向后翻转先前选择的行并翻转当前选择的行,但是我发现当我向下滚动tableview和flip view时,奇怪的事情出现在从未被选择的行上。
我试图在CustomCell类中创建属性,并尝试翻转但也没有运气。 我不确定这种方法是否正确,但除非向下滚动以加载其他行,否则它似乎可以正常工作。
如有任何建议,我将不胜感激。 谢谢
您应该使用这种视图结构制作一个自定义TableViewCell
-CELL
--CONTENT_VIEW
---1st_side
---2nd_side
和代码是
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:containerView cache:NO];
[firstView removeFromSuperview];
[containerView addSubview:secondView];
[UIView commitAnimations];
和后面的方法一样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.