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