這僅在打開和關閉鍵盤時發生,是否存在「UIResponder」問題?或者是關於「removefromsubview」?iPhoneSDK:UIBarButtonItem的選擇器方法針對錯誤的實例
我有一個自定義工具欄,好像我的UIBarButtonItems是針對QuestionTableViewController的錯誤實例,因此它觸發堆棧中的previosly加載控制器的選擇器方法,但不是當前對象的選擇器方法。
第一頁顯示正確,但是當第二次將此筆尖加載到導航控制器時,它會將第一個對象的操作方法而不是當前對象作爲目標。
在我的RootViewController的我加載eachtime這個坯不同的網頁:
QuestionTableViewController *questionViewController = [[QuestionTableViewController alloc] initWithNibName:@"QuestionTableViewController" bundle:nil];
然後在QuestionTableViewController的viewDidLoad方法我做到這一點;
UIBarButtonItem *rightButton = [[[UIBarButtonItem alloc] initWithTitle:nextArrow style:UIBarButtonItemStylePlain target:self action:@selector(localNextView:)] autorelease];
rightButton.width=120.0f;
self.customToolBar= [[[CustomToolbar alloc]
initWithFrame:CGRectMake(0,436,self.navigationController.view.frame.size.width, 44)] autorelease];
[self.customToolBar setItems:[NSArray arrayWithObjects:bckButton, rightButton, nil] animated:NO];
[self.navigationController.view addSubview:self.customToolBar];
-(void) localNextView:(id)sender {
//i.e when i am on the third page, here when i check the
//sender I see the object belongs to first page!!
}
然後我刪除它viewWillDisappear,我從navigationcontroller刪除它,未來視圖使用自己的工具欄,但不是previois實例,以確保;
[self.customToolBar removeFromSuperview];
self.customToolBar=nil;
你實現localNextView方法?如果是,那麼把代碼放在這裏..? – 2012-01-10 10:26:19