0
我是新手在iOS和我知道这个问题被问了很多次,但我没有得到solution.i使用tableview的应用程序在这里是我的tableview代码包含两个部分,我想用JSON Data.i填充此部分做了两个CustomCell。它很好地显示,但我无法填充我的JSON解析数据。如何设置数组数据在iOS中tableview第一部分的第一个值和tableview的第二个部分的剩余数组数据值?
我的代码是。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
static NSString *[email protected]"CellOne";
CustumCell *cellOne =[tableView dequeueReusableCellWithIdentifier:CellIdentifierOne];
if (cellOne == nil)
{
NSArray *nibOne=[[NSBundle mainBundle]loadNibNamed:@"CustumCell" owner:self options:nil];
cellOne=[nibOne objectAtIndex:0];
cellOne.userInteractionEnabled=NO;
}
{
[cellOne.spinner startAnimating];
NSDictionary *dict = [self.imageArray objectAtIndex:indexPath.section];
NSString *img2=[dict valueForKey:@"front_image"];
[cellOne.storeImage sd_setImageWithURL:[NSURL URLWithString:[img2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[UIImage imageNamed:@"Setting.png"] options:SDWebImageHighPriority completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
{
[cellOne.spinner stopAnimating];
cellOne.spinner.hidesWhenStopped=YES;
}];
}
return cellOne;
}
else
{
static NSString *[email protected]"CellTwo";
TableCell *cellTwo=[tableView dequeueReusableCellWithIdentifier:CellIdentifierTwo];
if (cellTwo == nil)
{
NSArray *nibTwo=[[NSBundle mainBundle]loadNibNamed:@"TableCell" owner:self options:nil];
cellTwo=[nibTwo objectAtIndex:0];
cellTwo.userInteractionEnabled=NO;
}
return cellTwo;
}
return nil;
}
这里泰伯维部分是两个,也为numberofRow代码
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
{
return 1;
NSLog(@"Images %@",self.imageArray);
}
else
{
return self.imageArray.count - 1;
}
}
在没有任何数据则显示,因为我想,但我不能够填补我的数据,请您提供我任何解决方案。
您可能不会尝试将您的数据应用到第1部分中的单元格。 – rmaddy 2014-11-04 06:19:00
@rmaddy没有尝试应用的方法吗? – 2014-11-04 06:20:15
您没有任何代码可以使用该部分中特定行的数据更新'cellTwo'。你不使用你的'imageArray'。 – rmaddy 2014-11-04 06:22:20