У меня есть один массив (arrData) и UITableViewCell reload arrData. arrData хранится в массиве объектов веб-службы. UITableViewCell в двух ярлыках и одном изображении, этикетке и загрузке изображений с помощью arrData. поэтому все метки и изображения перезагружаются в том же массиве, но я хочу перезагрузить различный-различный массив для каждой метки и изображения.UITableViewCell хранится в другом массиве
ViewController
#import "ViewController.h"
#import "MemberTableViewCell.h"
#import "member_details.h"
@interface ViewController()
{
NSArray *arrData;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.tabel_view setAllowsMultipleSelection:YES];
NSURLRequest *req=[[NSURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://edutimeapp.com/toshow/chamber-of-commerc/ws/fetch_member.php"]];
response =[[NSMutableData alloc]init];
[NSURLConnection connectionWithRequest:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[response appendData:data];
NSLog(@"error receving data %@",response);
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error;
NSLog(@"Error in receiving data %@",error);
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(@"response data %@",json);
NSArray *status = json[@"status"];
arrData = status;
[self.tabel_view reloadData];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray<NSIndexPath *> *selectedRows = [tableView indexPathsForSelectedRows];
if (selectedRows && [selectedRows containsObject:indexPath]) {
return 127.0; // Expanded height
}
return 50.0; // Normal height
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MemberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ht"];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.name.text= [[arrData objectAtIndex:indexPath.row] valueForKey:@"business_category_name"];
cell.title.text= [[[[arrData objectAtIndex:indexPath.row] valueForKey:@"business_details"] objectAtIndex:0] valueForKey:@"name"];
cell.email.text=[[[[arrData objectAtIndex:indexPath.row] valueForKey:@"business_details"] objectAtIndex:0] valueForKey:@"email"];
cell.image_view.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[[[arrData objectAtIndex:indexPath.row]valueForKey:@"business_details"]objectAtIndex:0] valueForKey:@"img_url"]]]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self updateTableView];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self updateTableView];
}
- (void)updateTableView
{
[self.tabel_view beginUpdates];
[self.tabel_view endUpdates];
}
@end
Ваш вопрос не ясно, предоставлять данные, содержащиеся в arrData. Также сообщите нам, что вы используете прототип ячейки или пользовательскую ячейку с xib? –
@BharatModi пользовательская ячейка с раскадрой, и я отредактирую свой вопрос. –
@BharatModi обновленный мой вопрос пожалуйста, повторно проверьте. thnx –