4
我已經爲我的應用程序編寫了一個自定義塞格,它部分遮蔽了源視圖控制器。賽格工作正常,我得到了預期的效果。當我按下按鈕將segue展開回源控制器時,應用程序崩潰。我用各種方法寫了一些日誌語句,但沒有任何東西被調用,所以我認爲我錯誤地將意見連接起來了。這裏的賽格代碼:自定義塞恩後退按鈕崩潰應用程序
- (void)perform {
NSLog(@"performing!");
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destView = ((UIViewController *)self.destinationViewController).view;
UIViewController *sourceController = ((UIViewController *)self.sourceViewController);
if (!_rewinding) {
[sourceView.window insertSubview:destView aboveSubview:sourceView];
destView.center = CGPointMake(sourceView.frame.size.width * 1.5, sourceView.center.y);
}
CGPoint newSourceCenter = CGPointMake(sourceView.frame.origin.x - sourceView.frame.size.width * 0.4, sourceView.center.y);
CGPoint newDestCenter = CGPointMake(sourceView.center.x + sourceView.frame.size.width * 0.1, sourceView.center.y);
[UIView animateWithDuration:1.4
animations:^{
if (_rewinding) {
NSLog(@"rewind in segu");
destView.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, destView.center.y);
sourceView.center = CGPointMake([UIScreen mainScreen].bounds.size.width*1.5, sourceView.center.y);
destView.alpha = 1.0;
} else {
destView.center = newDestCenter;
sourceView.center = newSourceCenter;
sourceView.alpha = 0.5;
}
} completion:^(BOOL finished) {
if (_rewinding)
NSLog(@"completed animation");
}];
}
一對夫婦的照片,以顯示發生了什麼。在點擊單元格時,詳細視圖從右側的屏幕向外滑動,並且源視圖幻燈片也向左滑動。
我使用[source presentViewController:dest]
但這樣做,試圖消除從窗口源視圖。由於我部分模糊了源,因此必須在動畫之後保留在屏幕上。什麼是正確的方法來設置?
編輯: 隨着殭屍的啓用,我在日誌中得到了這個。這對應於destinationViewController。所以很明顯它在賽季中沒有被保留。
[58880:c07] *** -[UIStoryboardUnwindSegueTemplate performSelector:withObject:withObject:]: message sent to deallocated instance 0x1f3c7fe0
什麼是確切的崩潰?你可以發佈符號化的崩潰日誌嗎? – 2013-04-10 16:58:11
@RoboticCat崩潰可能不是正確的用詞。我得到一個EXC_BAD_ACCESS。我正在研究發生的事情。 – brodney 2013-04-10 17:11:03
要清楚:您是說0x1f3c7fe0對應於您打開的前一個視圖控制器實例?如果一個視圖控制器被釋放,我會感到驚訝,但如果是這樣的話,我不知道如何尋找這個bug。 – 2013-04-10 17:59:25