2012-10-29 110 views
0

嗨,大家好有一些問題的指針,這是我的代碼IOS指針問題

NSArray *buttons = [NSArray arrayWithObjects: self.btn1, self.btn2, self.btn3,nil]; 

for(UIButton *btn in buttons){ 

    NSLog(@"%f, %f, %@", btn.bounds.size.width, btn.frame.size.height, btn.titleLabel.text); 
} 

的出來說就是"0.00000, 0.00000, button1" 任何想法怎麼回事???錯誤

+0

你試過btn.frame.size喜歡 – SachinVsSachin

+1

,你的按鍵設置框架? – 2012-10-29 09:51:15

+0

你在哪裏叫這個?你是否在代碼中創建按鈕,也許你確實有零按鈕(即size.width真的等於0)? –

回答

0

重試,此代碼只需設置幀viewDidLoad:方法,像波紋管..

- (void)viewDidLoad 
{ 

    ///set frame which you want.. 

    self.btn1 = [[UIButton alloc]initWithFrame:CGRectMake(10, 10, 100, 44)]; 
    self.btn2 = [[UIButton alloc]initWithFrame:CGRectMake(10, 70, 100, 44)]; 
    self.btn3 = [[UIButton alloc]initWithFrame:CGRectMake(10, 120, 100, 44)]; 
} 
+0

框架已被設置,按鈕已被鏈接在視圖控制器中。 – IsaacEllis