2012-08-31 48 views
-1

我試圖複製iPhone的聯繫人應用程序並在導航欄上創建按鈕。其實這個視圖並不是一個UINavigation控制器。我剛剛以編程方式添加了導航欄,但我正在努力在該導航欄上創建標題和按鈕。在導航欄上創建標題和按鈕

我使用下面的代碼

[[UIBarButton alloc]] initWithTitle:@"Done" 
           Style:UIBarButonItemStyleBorderd 
           target:Self 
           action:selector(btnClicked)]; 
self.navigationItem.rightBArButtonItem=btnDone; 
[self.view addSubview:navigationBar]; 

請模擬器參考iphone接觸應用。

任何幫助將不勝感激。

+2

在計算器上其他等環節,建議你把一些代碼,並解釋更多的細節你有什麼到目前爲止已經試過。 – BlueTrin

+0

對不起,我沒有在我的Mac系統的網絡接入,所以它是不可能把代碼.. – naveen

+0

你面臨的問題是什麼?你想添加BarButtonitem嗎? – iMeMyself

回答

0

試試這個代碼塊

UIBarButtonItem *rightButton = **[[UIBarButtonItem alloc] initWithTitle:@"Done" 
    style:UIBarButtonSystemItemDone target:nil action:nil];** 
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"]; 
item.rightBarButtonItem = rightButton; 
item.hidesBackButton = YES; 
[bar pushNavigationItem:item animated:NO]; 
[rightButton release]; 
[item release]; 

和經歷這樣this

相關問題