我有一個的MainWindow.xib文件:裏面的UITableView UINavigationController的不滾動
裏面有我定義一個UINavigationController作爲窗口RootViewController的。 UINavigationController有一個TableVC項目。
TableVC繼承自UITableViewController並實現了專用的Delegate和Datasource。
我覆蓋4種方法,viewDidLoad中初始化數據:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [data count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [data objectAtIndex:indexPath.row];
return cell;
}
我不認爲有什麼錯。
當我運行該項目時,出現了填充了我的數據的NavigationBar和TableView內部。但我不能滾動表格!?
任何提示表示讚賞。
我可能會詢問爲什麼你更喜歡將數據顯示爲每一行的單獨部分,而不是單獨一行的單獨部分? – Warkst
表格視圖如何添加到您的導航控制器? – jrtc27