2011-11-25 44 views
1

我有一個的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內部。但我不能滾動表格!?

任何提示表示讚賞。

+0

我可能會詢問爲什麼你更喜歡將數據顯示爲每一行的單獨部分,而不是單獨一行的單獨部分? – Warkst

+0

表格視圖如何添加到您的導航控制器? – jrtc27

回答

0

退房標籤:

- Scrolling Enabled 
- User Interaction Enabled 

爲您的tableView在你的筆尖文件(當然使用IB)

+0

我已經檢查過了,我已經檢查了兩個字段。 我確實改變了一些東西,以防止出現警告。我已禁用 - 定義上下文 - Privodes上下文 也許它與這些設置有關? –

0

編輯:

㈣只是看上Warkst的評論,我已經意識到你你的代碼有錯誤。林不知道它是否造成這個問題,但你應該修復它。

這條線的位置:

cell.textLabel.text = [data objectAtIndex:indexPath.row]; 

應該

cell.textLabel.text = [data objectAtIndex:indexPath.section]; 

由於您使用行不節。

這意味着您在每行中獲得的數據相同,因爲indexPath.row將始終爲零。我想建議不要使用UITableViewController。相反,在UIViewController的視圖內添加一個UITableView。如果您稍後需要移動表格,這將會變得更加靈活。

現在有很多原因可能導致您無法滾動。

  1. 它認爲它不需要滾動,即內容大小不比幀大小大。

    我不認爲這是因爲表視圖自己排序。但嘗試記錄框架和內容的大小隻是incase。

  2. 它沒有收到觸摸事件。

    這可能是因爲其他一些視圖劫持事件。嘗試重寫觸摸開始接觸結束等,只需記錄事件並調用超級。您將需要創建UITableView的子類。

    否則可能會有一個有趣的視圖結構。如果它在其父視圖框外,則不會獲得觸摸事件。嘗試在整個視圖之外移動整個視圖,以查看是否修復了這個問題。

  3. 滾動功能被禁用。

    檢查購買登錄在表視圖上的財產,scrollEnabled

這就是我現在所能想到的。讓我知道事情的後續。

+0

錯誤的地方,錯誤,移動評論。 – Warkst

相關問題