无法添加UIImageView?

时间:2011-04-21 07:30:55

标签: iphone objective-c ios4 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;
}

我的代码出了什么问题,我的照片没有出现。请帮帮我;(

1 个答案:

答案 0 :(得分:2)

您将需要UIImageView到scorllView。

- (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];
}