大家好 我寫這封信的viewDidLoad一個簡單的代碼,類的UITableViewController的孩子一樣之下,但按鈕是不可見的,而標題是可見的,當UIBarButtonItem在UINavigationBar中不可見時該怎麼辦?
,我點擊一個按鈕的另一件事在viewDidLoad方法ViewController.m,這是調用方法,該方法的代碼如下
//Code of button target method
-(void)statusMethod {
NSLog(@"statusMethod");
Status *ob=[[Status alloc]init];
[self presentModalViewController:ob animated:YES];
}
//Code of ViewDidLoad of Status.m
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, width, 43)];
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:navBar];
[navBar release];
UIBarButtonItem *home = [[UIBarButtonItem alloc] initWithTitle:@"HOME" style:UIBarButtonItemStylePlain target:self action:@selector(homeMethod)];
self.navigationItem.rightBarButtonItem = home;
UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonSystemItemAdd target:self action:@selector(addMethod)];
self.navigationItem.leftBarButtonItem = add;
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(10,10,width-20,25)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.text = @"Status";
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont systemFontOfSize:25];
label.textAlignment = UITextAlignmentCenter;
[navBar addSubview:label];
[label release];
任何想法,什麼是代碼問題? 我你不明白,那麼在哪裏再問我, 我要讚美,如果我會得到我的問題
您是使用導航控制器推送此視圖還是以模態視圖呈現? – benwong 2011-02-04 12:42:43