UIViewController提供了一个UINavigationController - 没有Nav Bar?

时间:2011-04-01 04:47:58

标签: cocoa-touch ios4 uiviewcontroller uinavigationcontroller uinavigationbar

我有一个带有表格的UIViewController。点击蓝色公开图标使视图控制器呈现UINavigationController。这工作正常,并确实使导航控制器显示,但没有导航栏,如下所示:

enter image description here enter image description here

我将如何让神奇的Navbar再次出现?我真的需要它在导航控制器中显示一个地图,而现在,这不起作用。

编辑:以下是我用来展示它的代码:

// scanned recently table view thing
- (void)tableView:(UITableView *)tableVieww didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableVieww deselectRowAtIndexPath:indexPath animated:YES];

    if(indexPath.section == 0) {
    NSString *info = [[scannedBackups objectAtIndex:indexPath.row] objectForKey:@"data"];
    NSArray *items = [info componentsSeparatedByString:@"&"];
    scanCodeViewCohntroller.dict = [[NSMutableDictionary alloc] init];
    int o;
    for (o = 0; o < [items count]; o++) {
        NSArray *secondItems = [[items objectAtIndex:o] componentsSeparatedByString:@"="];
        [scanCodeViewCohntroller.dict setObject:[secondItems objectAtIndex:1] forKey:[secondItems objectAtIndex:0]];
        }


        /*NSError *err;
        scanCodeViewCohntroller.dict = [NSPropertyListSerialization propertyListWithData:[foo dataUsingEncoding:NSUnicodeStringEncoding] options:NSPropertyListMutableContainersAndLeaves format:kCFPropertyListXMLFormat_v1_0 error:&err];
        if(err != nil) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Corrupted Data" message:[NSString stringWithFormat:@"Your Scanned Backup Data Store is corrupted. It will now be erased. %@", [err localizedDescription]] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
            [alert show];
            [alert release];
            scannedBackups = [[NSMutableArray alloc] init];
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString *documentsDirectory = [paths objectAtIndex:0];
            NSString *fullFileName = [NSString stringWithFormat:@"%@/scannedCodes.plist", documentsDirectory];
            [scannedBackups writeToFile:fullFileName atomically:NO];

        [tableView reloadData];
        }*/
        [scanCodeViewCohntroller.dict setObject:[[scannedBackups objectAtIndex:indexPath.row] objectForKey:@"date"] forKey:@"date"];
        [scanCodeViewCohntroller initalizeData];
    [self presentModalViewController:scanCodeViewCohntroller animated:YES];
    }
}

1 个答案:

答案 0 :(得分:2)

您需要获取导航控制器并调用setNavigationBarHidden:animated:。所以,试试:

[detailController.navigationController setNavigationBarHidden:NO animated:NO];

编辑:

根据你的编辑,我建议更换最后一行:

[self presentModalViewController:scanCodeViewCohntroller animated:YES];

使用:

[self.navigationController pushViewController:scanCodeViewCohntroller animated:YES];