我遇到了transitionWithView
和animateWithDuration
問題。我的animateWithDuration
塊之一不會轉換,這是一個突然的更改,並且transitionWithView
不會暫時禁用用戶交互。我檢查了文檔,並相信我正在做的一切正常,但顯然有些問題。這裏是兩個代碼塊:transitionWithView和animateWithDuration的問題
這是在我的主視圖控制器ViewController
其中有三個容器視圖/子視圖控制器。此塊移動其中一個容器視圖,但不會在轉換髮生時阻止用戶與ViewController
中的其他交互。
[UIView transitionWithView:self.view duration:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^ {
CGRect frame = _containerView.frame;
frame.origin.y = self.view.frame.size.height - _containerView.frame.size.height;
_containerView.frame = frame;
}completion:^(BOOL finished) {
// do something
}];
這是在我的一個容器視圖控制器中。動畫似乎沒有效果,因爲productTitleLabel
和productDescriptionTextView
的文本突然變化,就好像動畫塊不存在一樣。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.viewController toggleFlavoredOliveOilsTableView];
if (indexPath.row > 0) {
NSDictionary *selectedCellDict = [[_flavoredOliveOilsDict objectForKey:@"Unflavored Olive Oils"] objectAtIndex:indexPath.row - 1];
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^ {
self.viewController.productTitleLabel.text = [_flavoredOliveOilsTableView cellForRowAtIndexPath:indexPath].textLabel.text;
self.viewController.productDescriptionTextView.text = [selectedCellDict objectForKey:@"Description"];
}completion:nil];
if (indexPath.row == 1) {
[self.viewController setProductDescriptionTextViewFrameForInformationTab];
}
else {
[self.viewController setProductDescriptionTextViewFrameForNonInformationTab];
//self.viewController.productImageView.image = [UIImage imageNamed:[selectedCellDict objectForKey:@"Image"]];
}
}
}
我想,我的大部分動畫和過渡塊的預期不完全的工作問題有點關係。謝謝你的幫助。
編輯
我試圖做到的是移動的容器視圖中ViewController
並設置標籤,文本視圖和圖像視圖的文本和圖像性能;所有這些都是主要觀點。這些屬性的細節通過子視圖控制器發送。 transitionWithView
採用名爲toggleFlavoredOiveOilsTableView
的方法,該方法在didSelectRowAtIndexPath
中調用。我認爲問題在於我試圖同時調用兩個不同的動畫/轉換塊。
如果要同時爲兩個標籤設置動畫,請將這兩個標籤放在自己的標籤容器視圖上,然後將其用作「transitionWithView」的第一個參數。 – Rob
我現在有一部分工作正常。將animateWithDuration和UIViewAnimationOptionTransitions結合起來還是將transitionWithView和UIViewAnimationOptions結合起來是不可能的?看起來,當我有這些他們不工作,但如果我使用transitionWithView轉換選項它確實工作,同樣與動畫。我已經閱讀了文檔,似乎可以將它們全部結合在一起,但它並沒有爲我工作。 –
請參閱修訂後的問題。謝謝 –