0

iPad の UITableView にテキストが表示されないのはなぜですか?

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];

    if(tableView != nil)
        [tableView reloadData];
}

- (void)viewDidLoad {

    tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024) style:UITableViewStylePlain];
    tableView.delegate = self;
    [self.view addSubview:tableView];
}

- (void)doneButtonSelected:(id)sender {
    [self dismissModalViewControllerAnimated:NO];
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section == 0)
        return 1;
    else if(section == 1)
        return 2;

    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:CellIdentifier];

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    int section = indexPath.section, row = indexPath.row;
    if(section == 0) {
        if(row == 0)
            cell.textLabel.text = @"YAY";
    }
    else if(section == 1) {
        if(row == 0)
            cell.textLabel.text = @"BLACH";
        else if(row == 1)
            cell.textLabel.text = @"GAH";
    }

    return cell;
}

- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [theTableView deselectRowAtIndexPath:indexPath animated:YES];

    int section = indexPath.section, row = indexPath.row;

}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    if(section == 0)
        return @"Blah";
    else if(section == 1)
        return @"Hi";

    return @"Hello!";
}


@end
4

1 に答える 1

2

tableView.dataSource = 自己; ?

于 2012-07-27T20:47:52.977 に答える