2009-10-26 38 views
5

Ứng dụng iPhone New York Times có Thanh tab có năm mục thanh tab. Khi bạn chọn tab Mới nhất, ứng dụng sẽ hiển thị tiêu đề và tóm tắt/tóm tắt trong UITableView. Khi bạn chọn một câu chuyện riêng lẻ để đọc, Thanh tab biến mất và được thay thế bằng đầu trang và chân trang xuất hiện/biến mất tùy thuộc vào trạng thái của ứng dụng. Ứng dụng "ẩn" thanh tab như thế nào?"Ẩn" Thanh tab khi ấn một chế độ xem

Cảm ơn!

Trả lời

6

Trình điều khiển chế độ xem đang được đẩy lên ngăn điều khiển điều hướng có tham số ẩnBottomBarWhenPushed được đặt thành có. Mã sẽ trông giống như thế này trong -didSelectRowAtIndexPath của khung nhìn bảng.

NSDictionary *newsItem = [newsItems objectAtIndex:[indexPath row]]; 
NewsDetailViewController *controller = [[NewsDetailViewController alloc] init]; 
[controller setHidesBottomBarWhenPushed:YES]; 
[controller setNewsItem:newsItem]; 
[[self navigationController] pushViewController:controller animated:YES]; 
[controller release], controller = nil; 

Hãy xem documentation for hidesBottomBarWhenPushed.

p.s. Có thể bạn sẽ thấy rõ hơn về câu hỏi này nếu bạn thêm thẻ 'iphone' vào nó.

+0

Điều này phải được đánh dấu là câu trả lời đúng. Cảm ơn Matt anyways :) – Ahmed

2

Tôi có chế độ xem cần tùy chọn (tùy thuộc vào một số trạng thái khác) hiển thị thanh công cụ điều khiển điều hướng. Đây là giải pháp tôi đã sử dụng để hiển thị & ẩn thanh công cụ (có hoạt ảnh) khi chế độ xem xuất hiện & biến mất thông qua điều hướng. Nghe có vẻ như sau này.

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    // Show the nav controller toolbar if needed 
    if (someBool) 
     [self.navigationController setToolbarHidden:NO animated:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 

    // Hide the nav controller toolbar (if visible) 
    [self.navigationController setToolbarHidden:YES animated:animated]; 
} 
10

Triển khai đoạn mã này trong lớp mà bạn muốn ẩn thanh tab.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 
    // Custom initialization 
} 
self.hidesBottomBarWhenPushed = YES; 
return self; 
} 

Tất cả tốt nhất.

Các vấn đề liên quan