0
votes

I'm building my first basic tabbed, application with one of the views as a navigation controller that will display a view controller.

I'm running into an issue at the point the user selects a category from the first tableview as shown in the screenshot: http://www.cl.ly/7YOF

When another instance of the tableviewcontroller is loaded and pushed onto the stack of the navigationcontroller, the table is obstructed by the title bar: http://www.cl.ly/7ZRz

The table view select logic is below:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    KHCategory *selectedItem = [categoryArray objectAtIndex:indexPath.row];
    if (selectedItem.categories.count > 0) {
        KHCategoryTableViewController *nextCategoryController = [[KHCategoryTableViewController alloc] init];
        nextCategoryController.categoryArray = [[NSArray alloc] initWithArray:selectedItem.categories];
        nextCategoryController.title = selectedItem.labelValue;

        [self.navigationController pushViewController:nextCategoryController animated:YES];
        [nextCategoryController release];
    } else {
        NSLog(@"show detail view");
    }
}

EDIT: I should be clear that an instance of KHCategoryTableViewController is the root of my NavigationController and the NavController is wired up to the first tab of a TabController.

3

3 Answers

4
votes

Two interesting things: it measures 20 pixels down (size of status bar) and your line "nextCategoryController.title = ..." doesn't seem to do anything. So...

1) I assume you haven't used setStatusBarHidden?

2) Looks like navController stuff isn't working. Can you give the code from the appDelegate that creates the tabBar and NavController?

3) Add this code, and try calling [self dumpWindow: @"VDL"] from your Subcategory ViewDidLoad method. I find it invaluable whenever checking whether my view structure is correct.

- (void) dumpWindowFrom:(NSString *) fromText {
    [self dumpViews: nil from:fromText];
}

void dumpViewsRecursive(UIView* view, NSString *text, NSString *indent) {
    Class cl = [view class];
    NSString *classDescription = [cl description];

    if ([text compare:@""] == NSOrderedSame)
    NSLog(@"%d: %@ %@ %@", (int)view, classDescription, NSStringFromCGRect(view.frame), view.hidden ? @"Inv" : @"Vis");
else
    NSLog(@"%d: %@ %@ %@ %@", (int)view, text, classDescription, NSStringFromCGRect(view.frame), view.hidden ? @"Inv" : @"Vis");

    for (NSUInteger i = 0; i < [view.subviews count]; i++)
    {
        UIView *subView = [view.subviews objectAtIndex:i];
        NSString *newIndent = [[NSString alloc] initWithFormat:@"  %@", indent];
        NSString *msg = [[NSString alloc] initWithFormat:@"%@%d:", newIndent, i];
        dumpViewsRecursive (subView, msg, newIndent);
        [msg release];
        [newIndent release];
    }
}    

- (void) dumpViews: (UIView *) view {
    dumpViewsRecursive  (( (!view) ? [[UIApplication sharedApplication] keyWindow] : view), @"" ,@"");
}

- (void) dumpViews: (UIView *) view from:(NSString *) fromText{
    dumpViewsRecursive ((!view) ? [[UIApplication sharedApplication] keyWindow] : view, fromText, @"");
}

4) You could always just cheat and add:

CGRect frame = [nextCategoryController.view frame];
frame.origin.y = frame.origin.y+20.0;
[nextCategoryController.view setFrame:frame];
0
votes

Check the autoResizingMask of your KHCategoryTableViewController's view.

UINavigationController overview at iPhone Dev Center says:

Note: Because the amount of space available for the custom view can vary (depending on the size of the other navigation views), your custom view’s autoresizingMask property should be set to have a flexible width and height. Before displaying your view, the navigation controller automatically positions and sizes it to fit the available space.

0
votes

This issue became resolved when I built against iOS 4.3 and not iOS 5.