2014-01-16 2 views
-1

다음 코드가 있으며 uiview가 표시되지 않습니다. 중단 점을 적용했습니다. &보기가 0이 아니며 프레임이 지정된 크기로 설정되어 있는지 확인합니다. 내 uiviewcontroller에 표시되지 않습니까?하위 뷰를 추가하면 내 uiview가 표시되지 않습니다.

@property (nonatomic,strong) LoadingView *loadingView; 

self.loadingView = [[[NSBundle mainBundle] loadNibNamed:@"LoadingView" owner:self options:nil] objectAtIndex:0]; 
self.loadingView.frame = CGRectMake(110,170,100,100); 

[self.view addSubview:self.loadingView]; 
+0

뷰를 어디에 추가합니까? self.view가 이미로드되어 있는지 확인 하시겠습니까? 내 방법 중 하나에 – tadasz

+0

@ 타다시 –

답변

0

코드가 논리적으로 잘못되었습니다. LoadingView 클래스는 펜촉 멤버를 할당하기 전에 할당해야합니다.

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 
     NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"LoadingView" owner:self options:nil]; 
     self = [nibs objectAtIndex:0]; 
    } 
    return self; 
} 

귀하의 펜촉 할당 LoadingView 클래스의 initwithframe 방법에 있어야합니다. 그러면 뷰를 추가하면 다음과 같을 것입니다.

self.loadingView = [[LoadingView alloc] initWithFrame:CGRectMake(110,170,100,100)]; 
[self.view addSubview:self.loadingView]; 
관련 문제