2014-04-03 175 views
0

我試圖以表格格式顯示字符串數組。下面的方法被調用只有11倍,(畫面被充滿11行):UITableView不滾動,基於屏幕大小僅顯示11行

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *MyTableCell = @"MyTableCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyTableCell]; 

    if(cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyTableCell]; 
    } 

    cell.textLabel.text = self.MyArray[indexPath.row]; 
    return cell; 
} 

我的陣列有20個字符串,但只有11所得到的屏幕(我在模擬器上運行此)上顯示。桌子上沒有滾動條。屏幕卡住了11行。在我的XIB中,我只有這個tableview,沒有別的。有人可以幫助我,提前感謝!

回答

1

你可以顯示 - tableView:numberOfRowsInSection:方法。它是否返回

[self.MyArray count]; 

另外請記住,在模擬器中使用鼠標的滾輪不起作用。您必須單擊並拖動以模擬滾動。

+0

你知道什麼!問題在於我滾動的方式!我必須點擊並拖動,謝謝很多人!我對這整個系統實際上太新了。再次感謝 !!! – varun

+0

你也知道爲什麼表視圖不響應鍵盤上的箭頭鍵。它只能通過點擊和拖動來工作。我是否必須啓用某些功能才能使其工作? ?? – varun

+0

iPhone的鍵盤是否帶有箭頭鍵? :)(你不能在模擬器上比在真實設備上做更多) – nicael

相關問題