2013-07-27 6 views
0

config.h있는 UIImageView 하위 클래스 '이미지 속성

#define SomeImage [UIImage imageNamed:@"some_pic.png"] 

이이 나는 Something 서브 클래스 UIImageView의라는 이름의 클래스가, Something.minitWithFrame 방법 Something.h

config.h 수입이 :

self.image = SomeImage; 

문제는 내가 새로운를 만들 때입니다.슈퍼 뷰에 추가하면 아무 것도 볼 수 없습니다.

나는 initWithImage와 함께 문제를 처리 할 수 ​​있다고 생각하지만 내 코드가 작동하지 않는 이유를 알 수 없었다.

+0

시도 [[있는 UIImage ALLOC] initWithImage을 : @ ""] –

+0

당신이 반환 값을 확인 했습니까? 뷰 계층에'UIImageView'를 어떻게 추가합니까? –

답변

0

Something.m의 프레임에 대해 언급 했습니까?

그것은 잘 작동합니다, 예를

Something *something = [[Something alloc] initWithFrame:CGRectMake(10, 10, 200, 200)]; 
[self.view addSubview:something]; 

Something.m

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 
    } 

    self.image = SomeImage; 

    return self; 
} 
관련 문제