我不知道,爲什麼按鈕在工具欄設置爲隱藏和取消隱藏後消失。 我該如何解決它?當隱藏和取消隱藏工具欄時,按鈕項丟失
設置一個按鈕的代碼
-(void)viewDidAppear:(BOOL)animated {
//NSLog(@"viewDidAppear ");
[self becomeFirstResponder];
//Create a button
UIBarButtonItem *back = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRewind
target:self action:@selector(goback:)];
UIBarButtonItem *fixspace1 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:self action:nil];
UIBarButtonItem *next = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward
target:self action:@selector(gofwd:)];
UIBarButtonItem *stop = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self action:@selector(stopload:)];
UIBarButtonItem *refresh = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:@selector(refreshWeb:)];
[self.navigationController.toolbar setItems:[NSArray arrayWithObjects:fixspace1, back, fixspace1, stop, fixspace1, next, fixspace1, nil] animated:YES];
[self.navigationItem setRightBarButtonItem:refresh animated:YES];
[self.navigationController.view addSubview:self.navigationController.toolbar];
[stop release];
[next release];
[back release];
[refresh release];
[fixspace1 release];
}
,並設置我的按鈕,這個方法
-(void)viewDidAppear:(BOOL)animated
該代碼使用了隱藏工具欄
[self.navigationController setNavigationBarHidden:YES animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];
您可以發佈您的代碼,其中顯示的按鈕?這是你的viewDidAppear方法 – pheelicks 2010-03-20 11:17:26
是的,我更新它 – RAGOpoR 2010-03-20 14:03:46
這一行的目的是什麼: [self.navigationController.view addSubview:self.navigationController.toolbar]; 它似乎是多餘的或完全錯誤的。文檔說工具欄是「用於呈現動作表時」,我不相信你正在做。即使那樣,我也看不出爲什麼你需要將它添加到視圖中。 – Amagrammer 2010-03-20 16:47:51