我使用tableview從json文件填充數組...在我看來控制器我有tableview.when我運行項目我的表視圖編碼不執行。我不知道y?任何人都可以幫助我pls.This是我的視圖控制器文件使用TableView填充數組的JSON
#import "JSONparserViewController.h"
@implementation JSONparserViewController
@synthesize arraydata;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"No Of Elements in Array Data: %d",[arraydata count]);
return [arraydata count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSLog(@"%@",arraydata);
NSDictionary *aTweet = [arraydata objectAtIndex:[indexPath row]];
cell.textLabel.text = [aTweet objectForKey:@"name"];
// NSDictionary *newArray=[aTweet objectForKey:@"properties"];
//
// NSDictionary *newArray1=[newArray objectForKey:@"propertyMeta"];
// cell.detailTextLabel.text = [newArray1 objectForKey:@"name"];
// cell.detailTextLabel.text = [newArray objectForKey:@"value"];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.textLabel.minimumFontSize = 10;
cell.textLabel.numberOfLines = 4;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
//cell.detailTextLabel.text = [newArray1 objectForKey:@"type"];
// NSURL *url = [NSURL URLWithString:[aTweet objectForKey:@"profile_image_url"]];
// NSData *data = [NSData dataWithContentsOfURL:url];
// cell.imageView.image = [UIImage imageWithData:data];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSLog(@"HIIIIIIIIII");
return cell;
}
在上面的代碼中有一個NSLog也沒有執行.. – 2011-12-22 06:14:34
我認爲你正在尋找[xSON中的JSON解析](http://sugartin.info/2011/10/19/json-parsing-in -xcode /)。 – 2011-12-22 06:19:33
你一定忘記爲數據源設置委託。 – samfisher 2011-12-22 07:03:11