2012-06-19 63 views
0

我的類繼承自UITableViewCell,我做了一些自定義轉換以在圖像被選中時推送新的詳細視圖。在UITableViewCell類中推送一個詳細視圖

[UIView transitionWithView:self.masterView duration:0.5 options:UIViewAnimationOptionShowHideTransitionViews 
        animations:^ { 
         [self.masterView addSubview:self.detailImage]; 
        } 
        completion:nil]; 

我的代碼工作正常,在detailImage子視圖顯示了轉換,但這種轉換是不正是我想要的。我想要執行的是從底部向上的簡單過渡。 UIViewAnimation的列表中不包含此類動畫。

有什麼方法可以在不改變我的類繼承到UINavigationController的情況下使用該轉換嗎?

回答

1

如果我理解你的話,下面的代碼可能就是你想要的。

CGRect detailImageFrameOri = self.detailImage.frame; 
CGRect detailImageFrame = detailImageFrameOri; 
detailImageFrame.origin.y += self.detailImage.frame.size.height; 
self.detailImage.frame = detailImageFrame; 

[self.masterView addSubview:self.detailImage]; 

[UIView animateWithDuration:0.5 animations:^{ 
    self.detailImage.frame = detailImageFrameOri; 
}]; 

希望這可以幫助你。

編輯: 從上到下,

CGRect detailImageFrame = self.detailImage.frame; 
detailImageFrame.origin.y += self.detailImage.frame.size.height; 

[self.masterView addSubview:self.detailImage]; 

[UIView animateWithDuration:0.5 
       animations:^{ 
        self.detailImage.frame = detailImageFrame; 
       } 
       completion:^(BOOL finished) { 
        [self.detailImage removeFromSuperview];  
       }]; 
+0

那它究竟是:)))) – Malloc

+0

能否請您提供POP(解僱),其詳細視圖垂直(從上到下的方式)? – Malloc

+0

@luca你可以改變origin.y,方法是一樣的。像這樣detailImageFrame.origin.y - = self.detailImage.frame.size.height; – looyao

相關問題