0

I have added a new file to my project in that i am creating the screens programatically and i used following code to create a grouped table view with a title bar & 2 buttons on title bar, but its creating only grouped table but not title bar y it is so, can any one help me thanx in advance

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Add Item";
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] 
                                              initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
                                              target:self action:@selector(cancel_Clicked:)] autorelease];

    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
                                               initWithBarButtonSystemItem:UIBarButtonSystemItemSave 
                                               target:self action:@selector(save_Clicked:)] autorelease];

    self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];



    tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 415)style:UITableViewStyleGrouped];
    tableView.dataSource = self;
    tableView.delegate = self;
    [self.view addSubview:tableView];
}
4

3 回答 3

0
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc]
                                   initWithTitle:@"+"
                                   style:UIBarButtonItemStyleBordered
                                   target:self
                                   action:@selector(Add)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;

[journeylist.tabBarItem initWithTitle:@"Journey List" image:[UIImage imageNamed:@"listIcon-H.png"] tag:1];
journeylist.navigationItem.title =@"Journey List";

NSArray *controllers = [NSArray arrayWithObjects:journeylist,appstore,settings,about,nil];
self.viewControllers = controllers;

尝试这个。

于 2011-05-06T05:21:54.243 回答
0

我认为你必须像这样呈现它。

SomeViewController *controller = [[SomeViewController alloc]
                                initWithNibName:@"SomeViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]
                             initWithRootViewController:controller];
navController.navigationBar.tintColor = [UIColor grayColor];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[controller release];

编辑

当您使用表格视图显示该控制器时,您必须首先将其添加到导航控制器以显示导航栏。

于 2011-05-06T05:21:58.977 回答
0

您的表格框架在CGRectMake(0, 0, 320, 415)左上角,您需要为标题栏留出空间说CGRectMake(0, 40, 320, 415)

于 2011-05-06T05:29:41.420 回答