Vì vậy, ngay sau khi đẩy một bộ điều khiển nhằm tableView của tôi,Làm cách nào để thêm nút vào bên phải của điều hướng của tôi sau khi đẩy một bộ điều khiển chế độ xem khác?
// Override to support row selection in the table view. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here -- // for example, create and push another view controller. AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; [self.navigationController pushViewController:anotherViewController animated:YES];
Ok, vậy mà làm cho một trượt nhìn vào, và bạn có thể quay trở lại giao diện trước đó ("pop" giao diện hiện tại) bằng cách nhấn vào nút tự động tự động xuất hiện ở góc trên cùng bên trái của thanh điều hướng.
Ok, do đó nói rằng tôi muốn cư phía bên phải của thanh điều hướng với một nút DONE, như trong "Notes" ứng dụng mà đi kèm với iPhone. Tôi sẽ làm như thế nào?
Tôi đã thử mã như thế này:
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneFunc) ]; self.navigationController.navigationItem.rightBarButtonItem = doneButton ; // not it.. [doneButton release] ;
doneFunc được định nghĩa, và tất cả mọi thứ, chỉ cần nút không bao giờ xuất hiện ở phía bên phải ..
Bạn nên chấp nhận câu trả lời của Thomas thay vì câu trả lời của chính bạn. – titaniumdecoy