gpt4 book ai didi

ios - 将图像从JSON Url显示到TableView

转载 作者:行者123 更新时间:2023-12-01 20:12:43 25 4
gpt4 key购买 nike

为此收到3个错误

1) " [__NSCFString size]: unrecognized selector sent to instance "

2) " [NSNull length]: unrecognized selector sent to instance "

3) " [__NSCFString size]: unrecognized selector sent to instance "

下面是我的代码。你能帮我爱上这个问题吗?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
return matchesProfileArr.count;;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
displayCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];

if(!cell) {
cell = [[displayCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}

NSMutableDictionary *dict= [matchesProfileArr objectAtIndex:indexPath.row];
NSMutableDictionary *dictdetails=[dict objectForKey:@"ABSAdvancedSearch"];

cell.lblAge.text = [dictdetails objectForKey:@"age"];
cell.lblLocation.text = [dictdetails objectForKey:@"CustomerCity"];
cell.lblProfession.text = [dictdetails objectForKey:@"rb_profession_title"];
cell.lblEducation.text = [dictdetails objectForKey:@"rb_education_title"];
cell.lblFullName.text = [dictdetails objectForKey:@"Username"];
cell.profileImage.image = [dictdetails objectForKey:@"profile_pic"];

return cell;
}

最佳答案

dispatch_async(dispatch_get_global_queue(0,0), ^{
NSData * data = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:[dictdetails objectForKey:@"profile_pic"]]];
if ( data == nil )
return;
dispatch_async(dispatch_get_main_queue(), ^{

cell.image = [UIImage imageWithData: data];
});

});

请使用此代码,如果您使用dispatch_async,您的用户界面将不会卡住

关于ios - 将图像从JSON Url显示到TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37459074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com