在 viewDidLoad() 中调用方法
我有一个小问题,我已经实现了以下方法 我如何在此类
- (void)ladeImage {
id path = @"http://172.23.1.63:8080/RestfulJava/pics";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self.view addSubview:imgView];
但是
的 viewDidLoad() 方法中实现此方法。 有人可以帮我吗?
I have a little Problem, i have implemented the following method to
open an Image:
- (void)ladeImage {
id path = @"http://172.23.1.63:8080/RestfulJava/pics";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self.view addSubview:imgView];
}
But how i can implement this method in the viewDidLoad() Method of this class.
Could someone help me, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是在您的 UIViewController 子类的实现中,那么只需复制并;将 ladeImage 方法中的代码粘贴到 viewDidLoad 中(xcode 将为您准备方法实现并注释掉它们,如果您启动 VC 子类,则需要取消注释它)。
它应该看起来像这样:
当然,您可以保持原样,只在 viewDidLoad 的实现中调用
[self ladeImage];
。If this is within your implementation of a UIViewController subclass, then just copy & paste the code from within your ladeImage method into viewDidLoad (xcode will prepare method implementations for you and comment them out if you start a VC subclass, you need to uncomment it).
It should look like this:
of course you could leave things as they are and just call
[self ladeImage];
in your implementation of viewDidLoad.