0
하나의 .xib 파일에서 하나의보기를 추가하고 해당 클래스를 CustomViewClass
으로 수정합니다. 그 클래스의 내부에서 나는 .xib이 생성 될 때 호출 된 다시 쓰기 방법이 있습니다xib에서 사용자 정의보기를 호출 할 때 xib을 호출하면 충돌이 발생합니다.
- (id)initWithCoder:(NSCoder *)aDecoder{
if(self == [super initWithCoder:aDecoder]){
//Load the xib
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"SliderVW" owner:nil options:Nil];
self = [array objectAtIndex:0];
}
return self;
}
이 방법은 CustomViewClass
에 자기보기에 할당 할 하나의 XIB를 호출하지만 뭔가 잘못이다; 줄에 EXC_BAD_ACCESS가 표시됩니다.
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"SliderVW" owner:nil options:Nil];
이유를 이해할 수 없습니다.
고마워요 @ 니트 니. – NTTake
시나리오를 보면 클래스에서이 호출이 필요하지 않습니다. NSArray * array = [[NSBundle mainBundle] loadNibNamed : @ "SliderVW"owner : self options : nil]; 해당보기를 사용한 .xib에서 해당보기의 콘센트를 만들어이 사용자 지정보기를 직접 사용할 수 있기 때문입니다. –