2012-09-17 32 views
3

當我嘗試添加通過自動佈局中的所有視圖的約束,它出來以下消息:iOS6的界面生成器自動佈局:CRASH無法安裝上視圖

CRASH Unable to install constraint on view. 
Does the constraint reference something from outside the subtree of the view? 
That's illegal. 
constraint:<NSLayoutConstraint:0x756b510 UIPickerView:0x756f220.top == 
LoginView:0x75e9d30.top + 106> view:<LoginView: 0x75e9d30; 
frame = (0 15; 320 430); autoresize = RM+BM; layer = <CALayer: 0x75e9dc0>> 

任何人有一個想法?

+0

我剛收到這條消息。 –

+0

最後,我用另一個xib來處理IPHONE5長屏幕問題。 因爲我沒有足夠的時間來了解... – nullmicgo

+0

同樣在這裏,不是在我的iPhone上,而是在iPad和iPod上。 – gabrielpalomino

回答

-1

快速提示: 你必須創建3 XIB一個視圖控制器

  1. YourViewController.xib,
  2. YourViewController-568.xib,
  3. YourViewController〜ipad.xib

並在每個YourViewController.m中添加以下代碼 然後它將爲不同的用戶加載不同的視圖設備

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    // if(nibNameOrNil == nil){ 
     nibNameOrNil = @"YourViewController"; 

     if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ 
      if([UIScreen mainScreen].bounds.size.height > 480){ 

       nibNameOrNil = @"YourViewController-568"; 
       // iphone5+ 
      }else{ 
       // older than iphone5 
      } 
     } 
    // } 

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self){ 

    } 
    return self; 
} 
+0

ctrl-K是你的縮進朋友:-)另外請注意,該編號的列表項需要「1.」(注意該時間段之後的空格)而不是「1」「 – kleopatra

0

我在拾取器視圖上確實有同樣的問題。點擊一個輸入字段打開選擇器視圖,然後我選擇一些選擇器視圖並關閉它。當去另一個視圖,然後再回到pickerview我得到了錯誤提到。我通過關閉自動佈局解決了這個問題。這可以在文件檢查器上完成,只需取消自動佈局即可。

相關問題