웹 서비스에서 정보를 가져올 응용 프로그램을 만들었습니다. 지금까지는 NSLog를 사용하여 내용을 표시했지만 UITableViewCell에서로드하려고 시도했을 때 표시되지 않았습니다. 여기에 있습니다. 당신이 설정하는 그래서이 problem..Help주세요 UITableViewController..will에 파일을 추가하여 tableviewcontroller를 삽입 한 그UItbaleview 셀 JSON 내용이 iOS에 표시되지 않음
#import "TableViewController.h"
#import "JSON.h"
#import "SBJsonParser.h"
@interface TableViewController()
@end
@implementation TableViewController
@synthesize jsonurl,jsondata,jsonarray;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
}
jsonurl=[NSURL URLWithString:@"http://minorasarees.com/category.php"];
jsondata=[[NSString alloc]initWithContentsOfURL:jsonurl];
self.jsonarray=[jsondata JSONValue];
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [jsonarray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSLog(@"1");
NSLog(@"%@",jsonarray);
cell.textLabel.text=[jsonarray objectAtIndex:indexPath.row];
NSLog(@"2");
return cell;
}
-(void)dealloc
{
[super dealloc];
[jsonarray release];
[jsondata release];
[jsonurl release];
}
@end
에 대한 코드는 ...
"[jsonarray objectAtIndex : indexPath.row]"를 기록 했습니까? –
예. [jsonarray objectAtIndex : indexPath.row]에서 json 컨텐츠를 얻을 수 있습니다 .. – Dany
"cell.textLabel.text = @"test ";"로 텍스트를 설정할 수 있습니까? –