簡體   English   中英

iOS 5子視圖在TableView單元格中的兩個視圖之間翻轉

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM