0
是iOS開發中的新功能。如何以編程方式將所選圖像替換爲圖像?
我想用選定的圖像替換圖像。
我用下面的代碼。
-(void)imageTappedWithTag:(int)tag andType:(NSString *)type
{
NSLog(@"%@ %d",type,tag);
NSLog(@"test%@",[[ownerSwaps.imgArray objectAtIndex:tag]valueForKey:@"swap_image_thumb"]);
NSURL *url=nil;
NSString *urlStr=[NSString stringWithFormat:@"%@",[UIImage imageNamed:[[ownerSwaps.imgArray objectAtIndex:tag]valueForKey:@"swap_image_thumb"]]];
urlStr=[urlStr stringByReplacingOccurrencesOfString:@"\\" withString:@""];
NSString* urlTextEscaped = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
url=[[NSURL alloc]initWithString:urlTextEscaped];
SwapDetailImg.image=[UIImage imageNamed:@"fbicon.png"];
[SwapDetailImg setAlpha:0.2];
[self downloadImageWithURL:url completionBlock:^(BOOL succeeded, NSData *data) {
if (succeeded)
{
SwapDetailImg.image = [[UIImage alloc] initWithData:data];
[SwapDetailImg setAlpha:1.0];
}
}];
}
我有UITableViewCell
行。當我點擊滾動視圖水平ScrollView
,然後將圖像獲取與我的標題圖片更換。
請幫助我如何取代這個。