2014-11-04 96 views
0

我是新手在iOS开发我使用JSON数据数组显示tableview单元格数据我做不同的单元格为不同部分它正在工作,但现在我想在我的第一部分单元格只有数据数组第一个值和第二部分所有剩余的值是显示它如何可能?如何显示字典数组UITableview第一节中的第一个值和UITableview第二节中的剩余值?

我写我的第一单元中的代码,但它不工作

-(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; 
} 
} 

它显示在线路故障

NSDictionary *dict = [self.imageArray objectAtIndex:indexPath.section]; 

这里imagearray是JSON解析array.i知道这是问很多次,但我没有得到解决方案,请给我解决方案,如果有可能的话。

+0

尝试indexPath.row代替ndexPath.section – 2014-11-04 07:59:28

+0

错误显示什么? – 2014-11-04 08:11:32

+0

没有任何错误,但应用程序不运行@SaurabhPrajapati – 2014-11-04 08:15:20

回答

1

Ashish Gabani这里你的第一部只包含一个行比Defie×2个阵列等作为

NSArray *firstArray=[[NSArray alloc]init]; 
NSArray *secondArrayarray=[[NSArray alloc]init]; 

,然后写等作为

self.firstArray=[self.imageArray objectAtIndex:0]; 
self.secondArray=[NSMutableArray arrayWithArray:self.imageArray]; 
[self.secondArray removeObjectAtIndex:0]; 

First Section加载第一阵列数据和Second Section负载二阵列数据

希望它能帮助你。

相关问题