3

2番目のコントローラーがテーブルビューコントローラーであるアプリケーション(ナビゲーションコントローラー)があります。セグエを介して必要なデータを送信することはできますが、テーブルビューのエントリをプログラムで更新することはできません。

私はIOSを初めて使用します。

これは私のヘッダーファイルです

#import <UIKit/UIKit.h>
@interface HCIResultListViewController : UITableViewController

@property (strong,nonatomic) NSMutableDictionary *resultList;
@property (strong, nonatomic) IBOutlet UITableView *tableListView;

@end

これは私の実装ファイルです。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"HelloCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

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

cell.textLabel.text = @"Hello";

// Configure the cell...

return cell;
}

テーブルビューとコントローラーの操作方法を教えてもらえますか?

私はいくつかのドキュメントと例を調べましたが、本当に理解できませんでした

4

8 に答える 8

1

メソッドをこれに置き換えます:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
   {
    #warning Potentially incomplete method implementation.
    return 1;
    }
于 2013-03-06T10:50:27.120 に答える
1

これはまさに、Apple のテンプレートが次のように述べていることを意味しています。

#warning Potentially incomplete method implementation.

そこで適切な値を返す必要があります。セクションが 1 つしかない場合は1 を返しnumberOfSectionsInTableViewます (これは私が言う通常のケースです)。そして、埋めたい行の数を返しますnumberOfRowsInSection。これは、配列の数、フェッチされたデータセットの数、または動的でない場合はハードコードされた値/定数値である可能性があります。

cellForRowAtIndexPath次に、可能な各行/セクションの組み合わせに対して最大として呼び出されますが、最初から表示されているか、表示領域にスクロールされるセルに対してのみです。

于 2013-03-06T10:50:40.913 に答える
1

を 0UITableViewに設定した場合、あなたは何を期待しますか?numberOfRowsInSection

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0; // it should be size of your Array or List 
}

行数を配列サイズまたは配列内に入力しているデータに変更する必要がありますUITableView

于 2013-03-06T10:40:32.527 に答える
1

一部のデータを表示するには、少なくとも 1 を返す必要があります

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
于 2013-03-06T10:40:33.773 に答える
1

tableView のセクション数が 0 です! 1にする

于 2013-03-06T10:40:45.607 に答える
0
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{    
   //warning Incomplete method implementation.
    // Return the number of rows in the section.
   //   
  return 1;
}

このデータソース メソッドに従って、番号行が必要であり、0 を返す必要があるため、行を生成しないため、要件に従ってセルを生成しないでください。それ以外の場合は動的に行を生成し、少なくとも 1 行を返します。

于 2013-03-06T11:24:49.970 に答える