我的目標是使用自定義動畫製作自定義搜索引擎,如下所示: 我想讓segue使用destinationViewController中的按鈕來覆蓋sourceViewController中的一個按鈕,其效果類似於導航控制器的推動效果,即新按鈕應該將舊按鈕從右向左推開。在自定義搜索引擎中使用destinationViewController按鈕
根據需要我已經能夠使舊按鈕(從sourceViewController)搬走:
[UIView animateWithDuration:1.0 animations:^{
// set the target frame for animated view
sourceViewController.optionsButton.frame = leftButtonTargetFrame;
} completion:^(BOOL finished) {
[navigationController pushViewController:destinationViewController animated:NO];
// reset the button's frame back to its original frame
sourceViewController.optionsButton.frame = leftButtonInitFrame;
}];
但我努力使新的按鈕(從destinationViewController)中招的原因是。 我無法訪問destinationViewController的視圖元素:在執行segue時,它們未被實例化。我無法爲未實例化的按鈕設置動畫效果。
所以我怎麼能替換sourceViewController一個按鈕從destinationViewController一個按鈕?
這聽起來像是一個很好的解決方案。但它似乎有點迂迴,因爲每次我想修改按鈕時,我都必須在兩處更改代碼。有沒有辦法讓「真實」按鈕動起來? – Mischa 2013-03-09 15:36:36
文檔:根據[配置目標控制器當Segue前被觸發(http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ManagingDataFlowBetweenViewControllers/ManagingDataFlowBetweenViewControllers.html#//apple_ref/doc/uid/ TP40007457-CH8-SW4)和[αSegue公司的生命週期(http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomSegues/CreatingCustomSegues.html#//apple_ref/doc/uid/ TP40007457-CH16-SW2),當您執行segue時,目標視圖控制器應該被初始化。 – 2013-03-11 09:39:12