0

テーブルビューに配列を挿入するのに問題があります。私は配列を持っていて、それをに保存しましたalDescArray

これはalDescArray = ( "Block1", "Block2", "Block3" )、NSLogを介して印刷された場所です。間違っていると、テーブルにはコードのどの部分が表示されませんか?

- (void)viewDidLoad
{
    NSArray *BusRoute = alightDesc;
    int i;
    int count = [BusRoute count];
    for (i = 0; i < count; i++)
    {   
        NSDictionary *dic = [BusRoute objectAtIndex: i];
        NSDictionary *STEPS = [dic valueForKey:@"STEPS"];            
        alDescArray = [STEPS valueForKey:@"AlightDesc"];
   }
    [super viewDidLoad];
}

これはtableviewのコードです

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [alDescArray 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];
    }
    cell.textLabel.text = [alDescArray objectAtIndex:indexPath.row];    
    return cell;
}

plsは感謝を助けます

4

1 に答える 1

0

どうやらあなたのテーブルビューのデリゲート/データソースが設定されていません。

.h

YourClassName : ParentClass <UITableViewDelegate, UITableViewDataSource>

.m

- (void)viewDidLoad
{
    yourTableView.delegate = self;
    yourTableView.dataSource = self;
    NSArray *BusRoute = alightDesc;
    int i;
    int count = [BusRoute count];
    for (i = 0; i < count; i++)
    {   
        NSDictionary *dic = [BusRoute objectAtIndex: i];
        NSDictionary *STEPS = [dic valueForKey:@"STEPS"];            
        alDescArray = [STEPS valueForKey:@"AlightDesc"];
    }
    [super viewDidLoad];
}
于 2012-07-24T07:04:51.573 に答える