2011-10-18 106 views
0

我知道這是一個簡單的問題,但我無法將我的單元格分組到我的tableview中。我已將選項更改爲「分組」,但不起作用。TableView中的組單元格

哪裏可以解決問題?

它鏈接到文件的所有者,具有屬性,具有IBOutlet,並且它看起來是一個普通的TableView。

在此先感謝。

回答

1

,首先你把基礎的導航應用程序並打開RootViewController.xib並轉到下的TableView屬性屬性,選擇風格組和後RootViewController.m文件 並運行你的應用程序

// Customize the number of sections in the table view. 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 5; 
} 


// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 10; 
} 

-(void)setListTableView 
{ 
    mytableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 59, 319, 358) style:UITableViewStyleGrouped]; 
    mytableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched; 
    mytableView.backgroundColor = [UIColor clearColor]; 
    mytableView.opaque = NO; 
    mytableView.delegate = self; 
    mytableView.dataSource = self; 
    mytableView.scrollEnabled = YES; 
    mytableView.scrollsToTop = YES; 
    [self.view addSubview:mytableView]; 
} 
+0

的問題是,我在一個NavigationController中的新ViewController中編寫了一個TableView。這就是爲什麼我說它不起作用。我已經在一個新項目中完成了它,它可以工作,它顯示了單元格分組。爲什麼它不能在我的UITableViewController中工作?無論如何感謝您的回答。 – agapitocandemor

+0

檢查我更新的代碼 –

+0

好吧,那就是我正在尋找的:'initWithStyle:UITableViewStyleGrouped' – agapitocandemor