无法添加UIImageView?

发布于 2024-11-02 19:09:29 字数 1117 浏览 1 评论 0原文

我尝试将图像添加到我的视图中,在 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;
}

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

I try to add Image into my view that in UIScrollView

here is my .h

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

@property (nonatomic, retain) UIImageView *lineImg;

@end

and here is my .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;
}

What's wrong with my code , My pic didn't appear. help me please ;(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2024-11-09 19:09:29

您将需要将 UIImageView 转换为 scollView。

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

You will needed to the UIImageView to the 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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文