2015-08-28 72 views
0

這裏是我的代碼:一次初始化或分配可變

- (IBAction)btnFutApt:(UIButton *)sender { 

    CGSize rec; 
    rec.height = view.frame.size.height; 

    sender.selected = !sender.selected; 
    CGRect newFrame ; 
    NSLog(@"HEFU %f ", rec.height); 

    if (sender.selected) { 
     viewFuExtMain.hidden = TRUE; 
     viewFuIntMain.hidden = true; 
     newFrame = viewFutAptMain.frame; 
     newFrame.size.height = 115 ; 
     viewFutAptMain.frame = newFrame; 


    } 
    else { 

     viewFuExtMain.hidden = FALSE; 
     viewFuIntMain.hidden = FALSE; 
     newFrame = viewFutAptMain.frame; 
     newFrame.size.height = rec.height; 
     viewFuMain.frame = newFrame; 



    } 
    NSLog(@"HEFU %f", rec.height); 
} 

希望變量將存儲的高度和不惜任何代價不會改變..

回答

0

寫getter方法初始化與存儲的值。試試我提到下面的代碼

@property(nonAtomic, Strong, get) CGFloat *Height; 
+0

不明財產得到init方法 – iDeepak

+0

你必須給價值 –