2011-04-21 11 views
0

는 여기UIImageView를 추가 할 수 없습니까?

UIScrollView 내 .H

@interface NormalDetail : UIViewController <UIScrollViewDelegate> { 
    IBOutlet UIImageView *lineImg; 
} 

@property (nonatomic, retain) UIImageView *lineImg; 

@end 

것을 내보기에 이미지를 추가하려고 여기 뭐가 잘못 내하는 .m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    //Set ScrollView 
    scrollView.contentSize = CGSizeMake(320.0f, 1800.0f); 
    //End Set ScrollView 
    [self setupTextView]; 
} 


- (void) setupTextView 
{ 
    textDescription.scrollEnabled = NO; 
    NSString *foo = @"Hello Test"; 
    textDescription.text = foo; 
    /*Here is something for dynamic textview*/ 
    CGRect frame; 
    frame = textDescription.frame; 
    frame.size.height = [textDescription contentSize].height; 
    textDescription.frame = frame; 
    /**/ 

    int linePosition = frame.size.height+20; 
    lineImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line.png"]]; 
    CGRect line2Frame = CGRectMake(-8, 600, 328, 10); 
    lineImg.frame = line2Frame; 
} 

은 내 코드, 내 그림이 나타나지 않았다. . 제발 도와 (

답변

2

당신이 scorllView에있는 UIImageView에 필요한 것

- (void) setupTextView 
{ 
    textDescription.scrollEnabled = NO; 
    NSString *foo = @"Hello Test"; 
    textDescription.text = foo; 
    /*Here is something for dynamic textview*/ 
    CGRect frame; 
    frame = textDescription.frame; 
    frame.size.height = [textDescription contentSize].height; 
    textDescription.frame = frame; 
    /**/ 

    int linePosition = frame.size.height+20; 
    lineImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line.png"]]; 
    CGRect line2Frame = CGRectMake(-8, 600, 328, 10); 
    lineImg.frame = line2Frame; 

    //Add the image view as a subview to yout scrollview. 
    [scrollView addSubView:lineImg]; 
} 
+0

와우 들으 내가 :) – crazyoxygen

+1

을 가지고 또한 당신이 XIB에서 개체를 추가 한 경우에만'IBOutlet'를 사용합니다. 'IBOutlet'을 사용할 때, 선언을 위해서 IBOutlet Class * ObjectName; 으로 사용하십시오. 및 '@property와 같은 속성을 만들 (비 원자, 유지) 함께 IBOutlet 클래스 *의 ObjectName,' 및 XIB와 객체를 바인딩하는 것을 잊지 마세요. –

+0

@Himanshu에 전적으로 동의합니다. +1 – rckoenes

관련 문제