2014-06-13 60 views
0

打電話時,我得到一個錯誤presentViewControlleriOS的錯誤:斷言失敗

它充當如果它本來是與約束,但是,甚至當我刪除所有,但它仍然發生。

的導致崩潰的代碼行是:[[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:nil];

只有當該設備是景觀,誤差會破滅,但同時呼籲在縱向這一行,一切正常。

我得到的錯誤是:

*** Assertion failure in -[UIView _edgeExpressionInContainer:vertical:max:], /SourceCache/UIKit/UIKit-2935.137/NSLayoutConstraint_UIKitAdditions.m:2815 

請記住,這是在賽格瑞一流的最後一道防線。

編輯:到目前爲止,它似乎像錯誤可能是在這條線:源代碼視圖控制器中的self.view setTranslatesAutoresizingMaskIntoConstraints:NO];。 但是,出於設計目的,這條線對於整理視圖至關重要。整個代碼塊在這裏:

[refreshNotes setAutoresizingMask:(UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleLeftMargin)]; 
    [[refreshNotes.subviews objectAtIndex:0] setFrame:CGRectMake(refreshNotes.bounds.origin.x, 17, refreshNotes.bounds.size.width, refreshNotes.bounds.size.height)]; 
    [[refreshNotes.subviews objectAtIndex:0] setTintColor:[UIColor colorWithRed:95.0/255.0 green:49.0/255.0 blue:187.0/255.0 alpha:1]]; // lighter purple so it doesn't appear black 

    [self.view setTranslatesAutoresizingMaskIntoConstraints:NO]; 
+0

通常斷言失敗伴隨着描述原因的附加文本。在這種情況下是否有任何這樣的附加文字? –

+1

如果你看@kuchumovn答案[這裏](http://stackoverflow.com/questions/15139909/auto-layout-screen-rotation-and-uiview-animation),這是一個解決你的同樣的問題,作爲一個稍微不同的問題的答案,他說*擁有* [self.view setTranslatesAutoresizingMaskIntoConstraints:NO]; *在他的目的地VC中弄虛作假。 – rdurand

+0

熱舔:沒有這是我得到的唯一(除'lldb'外) rdurand:我有我的源代碼視圖控制器中的這一行,但它是必要的一些設計。我將在答案編輯中發佈整個代碼塊。 – Sam

回答

0

rdurand概述了導致此錯誤的代碼行。這是[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];

我真的不知道到底發生了什麼,但我將bool參數從NO更改爲YES。該應用程序不會再崩潰。

非常感謝您的幫助。