开发者

Help debugging UITableView, shows no data

I was first tasked to create a popover that came from a BarButtonItem, and then based on selection in that popover (which was a tableview), another popover would present itself from the cell with the data. The data I had was correctly presented that way. In the debugger, I still see the data in my cellForRowAtIndexPath with NSLog what's in the self.CategoriesArray. For some reason though, the data will not show... Now however, they don't want the initial popover, and just one popover that comes from the BarButtonItem. For the life of me, I cannot figure out why my data is not being presented since all that change should be is replacing the first UITableView in the popover, with the second UITableView. Unless I'm missing something..... Any help would be appreciated. Thanks!

cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == _filterTableView || tableView == _categoriesTableView) {

        static NSString *simpleIdentifier = @"SimpleIdentifier";
        UITableViewCell *simpleCell = [tableView dequeueReusableCellWithIdentifier:simpleIdentifier];
        if (simpleCell == nil) {
            simpleCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleIdentifier];
        }
        NSUInteger row;
        row = [indexPath row];
        simpleCell.textLabel.textColor = [UIColor whiteColor];
        simpleCell.selectionStyle = UITableViewCellSelectionStyleNone;

        // first popover
        if (tableView == _filterTableView) {
            simpleCell.textLabel.text = [_filterArray objectAtIndex:row];
            return simpleCell;
        }
        // second popover
        else if (tableView == _categoriesTableView) {
            simpleCell.textLabel.text = [_categoriesArray objectAtIndex:row];
return simpleCell;
    }

- (IBAction)FilterButtonPressed:(id)sender {

            // This part works for two popovers
//        UIViewController *contentViewController = [[UIViewController alloc] init];
//        self.FilterTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 200, 150) style:UITableViewStylePlain];
//        self.FilterTableView.delegate = self;
//        self.FilterTableView.dataSource = self;
//        self.FilterTableView.bounces = NO;
//        self.FilterTableView.scrollEnabled = NO;
//        self.FilterTableView.backgroundColor = [UIColor clearColor];
//        contentViewController.contentSizeForViewInPopover = CGSizeMake(200, 150);
//        contentViewController.view = _filterTableView;
//        
//        self.FilterPopoverController = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
//        [self.FilterPopoverController presentPopoverFromBarButtonItem:_filterButton permittedArrowDirections:UIPopoverArrow开发者_JAVA技巧DirectionAny animated:YES];
//        
//        [contentViewController release];

        // New code tfor one popover
        [self loadCategories];
        UIViewController *contentViewController = [[UIViewController alloc] init];
        self.CategoriesTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) style:UITableViewStylePlain];
        self.CategoriesTableView.delegate = self;
        self.CategoriesTableView.dataSource = self;
        self.CategoriesTableView.bounces = NO;
        self.CategoriesTableView.scrollEnabled = YES;
        self.CategoriesTableView.backgroundColor = [UIColor clearColor];
        contentViewController.contentSizeForViewInPopover = CGSizeMake(320, 500);
        contentViewController.view = _categoriesTableView;

        self.FilterPopoverController = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
        self.FilterPopoverController.delegate = self;
        [self.FilterPopoverController presentPopoverFromBarButtonItem:_filterButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];        
        [contentViewController release];

    }
}


I recognize this code from your other question. :) You're setting your text color to white, and the default background color of the cell is also white. Is this the same bug? Try setting a different background color for your cell.

If that doesn't fix it, there's one other thing you could check. You're setting this:

contentViewController.view = _categoriesTableView;

but it's not clear from your code where _categoriesTableView comes from. Do you have @synthesize CategoriesTableView = _categoriesTableView; at the top of your implementation?

Set a breakpoint on that view assignment and make sure _categoriesTableView isn't nil.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜