-2

配列に問題があります。MutableArray から TableView データを読み込もうとしました。しかし、試してみると失敗しました...間違いはありませんが、TableViewを開くとViewが空です。これが私のコードです。何かアイデアがあるかもしれません。

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView reloadData];
    NSLog(@"Wert von tE nachdem die Seite geladen hat, ist wie folgt: %d", trickEins);

}

-(NSMutableArray *)mutableArrayAusTricksArray:(NSArray *)array {

    NSLog(@"Wert: %d", trickEins);

    self.tricksFavoriten = [NSMutableArray new];

    if (trickEins  == 2)  {[self.tricksFavoriten addObject:@"Body Feint"];};
    if (trickZwei  == 2)  {[self.tricksFavoriten addObject:@"Stepover"];};
    if (trickDrei  == 2)  {[self.tricksFavoriten addObject:@"Reverse Stepover"];};
    if (trickVier  == 2)  {[self.tricksFavoriten addObject:@"Ball Roll"];};
    if (trickFuenf == 2)  {[self.tricksFavoriten addObject:@"Drag Back"];};
    [self.tableView reloadData];

    return self.tricksFavoriten;

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.

    return [self.tricksFavoriten count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell.textLabel.text = self.tricksFavoriten[indexPath.row];


    return cell;
}



@end
4

1 に答える 1

2

セクション数は 1 にする必要があります。

編集: viewDidLoadで:

- (void)viewDidLoad
{
   [super viewDidLoad];

   [self.tableView reloadData];
   NSLog(@"Wert von tE nachdem die Seite geladen hat, ist wie folgt: %d", trickEins);
   [self mutableArrayAusTricksArray:[[NSArray alloc]init]];

}
于 2013-07-18T20:07:15.023 に答える