2012-11-21 38 views
1

由於大約一百個原因,我只需以編程方式製作此UIViewController子類視圖。只有一個,每隔一個視圖使用IB來進行佈局。以編程方式設置一些界面生成器選項

那麼現在我已經着陸了任務,使應用程序自動旋轉。大多數情況下都很好,但我需要幫助瞭解其中一些佈局選項...特定於自動調整和對齊

如何在此處設置此對象(這將是對象稱爲「標題」,因此[header setAutoresizingMask:...]

enter image description here

而且還有這一個

enter image description here

這那些爲_mapView

伊夫那種不斷罵個可用的選項,但無論是其沒有作出任何明顯的差異,或IM不設置正確的選項...

header = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [header setFrame:CGRectMake(0, 0, self.view.frame.size.width, 170)]; 

    // this one shoves the header button when in landscape mode to out of view :\ 
    [header setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin]; 
    // the header remains left aligned when in landscape mode... 
    [header setContentVerticalAlignment:UIControlContentHorizontalAlignmentCenter]; 


    [header setBackgroundImage:[[UIImage imageNamed:@"header.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; 
    [header setBackgroundImage:[[UIImage imageNamed:@"header.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateHighlighted]; 

    [header addTarget:self action:@selector(goHome) forControlEvents:UIControlEventTouchUpInside]; 



    _mapView = [[[SPMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)] autorelease]; 
    [_mapView setDelegate:self]; 




    [self.view addSubview:_mapView]; 
    [self.view addSubview:header]; 

回答

2

的第一個:

CGRect newFrame = mainView.frame; 
     newFrame.origin = CGPointMake(160, 170); 
     newFrame.size = CGSizeMake(768, 170); 
     myView.frame = newFrame; 
     myView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin; 

和第二個:

CGRect newFrame = mainView.frame; 
      newFrame.origin = CGPointMake(160, 416); 
      newFrame.size = CGSizeMake(320, 247); 
      myView.frame = newFrame; 
      myView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 
+0

嘗試這些了,謝謝你的回覆迅速:) – RedactedProfile

+0

沒有問題的隊友;)如果有任何問題,隨時問:) – Rudi

+1

是的工作,不得不調整起源和尺寸,但否則看起來不錯,謝謝! – RedactedProfile

相關問題