2
我有一個歷史記錄頁面,這是一個包含5行的UItableview。我已經原型小區設置到我想要的規格,並加入這段文字對應的historyviewcontroller.h文件:沒有出現在桌面視圖中的單元格
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HistoryItem"];
return cell;
}
我沒有看到任何細胞,當我運行的應用程序。我明顯錯過了一些東西,但我看不出什麼。
我在HistoryViewController.m被放置這個,這是正確的位置?當有人點擊歷史記錄按鈕(位於主視圖中)時,我的歷史視圖就會顯示出來。 – Jonnybellman
另外,我用上面的代碼,我有各種錯誤。 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@「HistoryItem」];如果沒有錯誤,我必須編輯爲: //如果單元格不爲零,則表示它已經創建並正確出列。如果(cell == nil) {//通過alloc init創建您的單元格在這裏 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@「HistoryItem」]; } return cell; } – Jonnybellman
我發現另一個SO鏈接解決了我的問題。在創建新問題之前,我應該看起來更難一些http://stackoverflow.com/questions/7910206/how-can-i-create-an-uitableview-on-xcode-4-2-for-ios-5 – Jonnybellman