2011-10-07 58 views
0

我有我的縮放按鈕,CGRectMake的問題。正如你可以在下面看到的那樣,它應該可以工作,但它根本不會改變。問題與CGRectMake的按鈕大小

GameTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
GameTwo.titleLabel.font = [UIFont systemFontOfSize:22]; 
GameTwo.titleLabel.lineBreakMode = UILineBreakModeHeadTruncation; 
[GameTwo setTitle:(@"Game Two") forState:UIControlStateNormal]; 
GameTwo.frame = CGRectMake(10, 10, 100, 50); 
[GameTwo addTarget:self action:@selector(gameTwo) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:GameTwo]; 

我想我也有兩個問題。如何根據縱向模式和橫向模式更改按鈕尺寸。

+2

你知道一個8×像素按鈕將是什麼樣子? – Joe

+0

+1喬我改變了它。 –

+1

好的更好,也許現在你可以看到一些有意義的事情,現在看看這個文章http://www.techotopia.com/index.php/IOS_4_iPhone_Rotation,_View_Resizing_and_Layout_Handling並轉到名爲「編碼佈局和大小的變化」 – Joe

回答

0
GameTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
GameTwo.titleLabel.font = [UIFont systemFontOfSize:22]; 
GameTwo.titleLabel.lineBreakMode = UILineBreakModeHeadTruncation; 
[GameTwo setTitle:(@"Game Two") forState:UIControlStateNormal]; 
GameTwo.frame = CGRectMake(10, 10, 100, 50); [GameTwo addTarget:self 
action:@selector(gameTwo) 
forControlEvents:UIControlEventTouchUpInside]; [self.view 
addSubview:GameTwo]; 

完美的作品。 (這是在原來的問題) 的問題是,我試圖用另一種功能放置了按鈕應該去。我不明白在這種情況下前兩個變量(10, 10...)是按鈕的位置。現在我做了。 乾杯。

1

一個很好的經驗法則它應該工作,但它根本不會改變」錯誤是在其他地方尋找錯誤。

你檢查GameTwo類實現(超)徹底? 您是否設置了自動調整遮罩? 你的地方設置一個界限變更通知的框架?

+0

這是一個很好的規則。我真的想到了。讓我發表答案。對於那個很抱歉。 –