0
ボタンのタップでURL(xmlファイルにある)の画像を表示する方法を知りたい。URLから画像を表示してUIButtonのタップに表示する方法は?
ボタンをタップした後ボタンのタップでURL(xmlファイルにある)の画像を表示する方法を知りたい。URLから画像を表示してUIButtonのタップに表示する方法は?
ボタンをタップした後UIImage *pImage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]];;
[imageView setImage:pImage];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(20, 20, 200, 44); // position in the parent view and set the size of the button
[myButton setTitle:@"Click Me!" forState:UIControlStateNormal];
// add targets and actions
[myButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
// add to a view
[superView addSubview:myButton];
と機能
-(void)buttonClicked{
//urlString should be your image url which you want to access
NSURL *url = [[NSURL alloc] initWithString:urlString ];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
}
表示したいの使用イメージ.........
ここ応答&何ですか? – Ans