2013-05-15 3 views
0

내 UIView의 init 메서드에서 self.frame.size.height를 호출하면 결과가 0이됩니다.초기화 메서드에서 UIView 크기 가져 오기

의 UIView :

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     NSLog(@"Content,init: %f",self.frame.size.height); 
... 

UIView의 생성 :

m_content = [[Content alloc] init]; 
m_content.frame=self.frame; 

답변

0

프레임 (및 그것과 크기)을 초기화 루틴에서 설정된 도착하기 때문이다.

대신

m_content = [[Content alloc] init]; 
m_content.frame=self.frame; 
+0

m_content = [[Content alloc] initWithFrame:self.frame]; 

사용

사실 모두 함께 답을 알고 있었다. 알아 내려면 약간의 시간을 들여야합니다. 나는 사람들이 저 게시물을 만들어서 그 문제를 얻는 시간을 절약 할 수 있다고 생각했습니다. – asdf

관련 문제