2011-05-04 33 views
0

我試圖創建一個看起來像下面這樣的觀點: enter image description here創建蘋果iPad郵件視圖

我知道這是一個UISplitView,但我的問題是,在創建UIToolBar那是UITableView的下方左側以及如何在詳細視圖頂部創建圖標(帶有垃圾桶標識,回覆和新消息的圖標)。我該怎麼做呢?

回答

1

如果您在Interface Builder中查看UISplitView項目的DetailView.xib,您可以將UIBarButtonItems拖放到其中包含的工具欄上。

要獲得popover控制器中的工具欄,您可以使用UINavigationController附帶的toobar。下面的代碼應該給你一個如何做到這一點的想法。將此代碼添加到RootViewController。

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.clearsSelectionOnViewWillAppear = NO; 
    self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); 

    //setup toolbar 
    self.navigationController.toolbarHidden = NO; 
    UIBarButtonItem *refreshItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];  
    [self setToolbarItems:[NSArray arrayWithObjects:refreshItem, nil]]; 
    [refreshItem release];  

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60.0, 10.0, 200.0, 21.0)]; 
    label.backgroundColor = [UIColor clearColor]; 
    label.textColor = [UIColor whiteColor]; 
    label.text = @"This is a label on the toolbar"; 
    [self.navigationController.toolbar addSubview:label]; 
    [label release]; 
} 
+0

如果你不介意我問,如果我想在DetailView上有一個工具欄?與上面的代碼一樣? – adit 2011-05-04 22:10:57

+0

您可以將工具欄拖到IB中的DetaiView上。 – jaminguy 2011-05-04 22:18:39

+0

其實我的詳細視圖已經有了一個UITableView,所以我只需要拖動它的一個工具欄?有沒有一種方法可以通過編程來實現 – adit 2011-05-04 22:23:25