2012-07-15 60 views
1

我希望我的UIButton始終保持在屏幕底部而不必始終調整X.這是我的代碼,隱藏我的按鈕水平模式。使UIButton在頁腳旋轉期間保持連接狀態

UIImage *greenBtnImage = [[UIImage imageNamed:@"green-btn-iphone.png"]stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0]; 
    bt = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [bt setBackgroundImage:greenBtnImage forState:UIControlStateNormal]; 
    bt.frame = CGRectMake(14.0f,406.0f,292.0f,41.0f); 
    [bt addTarget:self action:@selector(didClickButton:) 
     forControlEvents:UIControlEventTouchUpInside]; 
    [bt setTitle:@"OK" forState:UIControlStateNormal]; 
    bt.autoresizingMask = (UIViewAutoresizingFlexibleWidth); 

    bt.autoresizesSubviews = YES; 
    [self.view addSubview:bt]; 

我無法找到答案如何以編程方式執行此操作。謝謝。

回答

1

如果我明白你很好,這應該幫助:

bt.autorezisingMask = UIViewAutoresizingFlexibleTopMargin; 

免責聲明:我從來沒有認爲自己編程,到目前爲止,僅在與界面生成器結合autorezising。

+0

正是我需要的。謝謝 – Vad 2012-07-15 18:18:23