0

ナビゲーションコントローラーに接続された1つのテーブルビューコントローラークラスがあります。

しかし、それを実行したときにセルが表示されなかった理由がわかりません。タブバー付きのナビゲーションバーしかありません。ここに私のコードがあります:

もう 1 つの問題は、上部のナビゲーション バーに両端揃えボタンを配置したいのですが、すべてのボタンが右側にあることです。

 self.navigationItem.rightBarButtonItems = buttons;

助けてください!前もって感謝します!

![ここに画像の説明を入力][2]

- (void)viewDidLoad
{
[super viewDidLoad];

 UIBarButtonItem *menuButton= [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleDone        target:self action:@selector(menu:)];
UIBarButtonItem *yearButton= [[UIBarButtonItem alloc] initWithTitle:@"Year" style:UIBarButtonItemStyleDone target:self action:@selector(year:)];
UIBarButtonItem *weekButton= [[UIBarButtonItem alloc] initWithTitle:@"Week" style:UIBarButtonItemStyleDone target:self action:@selector(week:)];
UIBarButtonItem *reportButton= [[UIBarButtonItem alloc] initWithTitle:@"Report" style:UIBarButtonItemStyleDone target:self action:@selector(report:)];

NSArray *buttons = [NSArray arrayWithObjects:menuButton,yearButton,weekButton,reportButton,nil];
self.navigationItem.rightBarButtonItems = buttons;


}

- (void)viewDidUnload
{

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (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 = @"Cell";
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

// Configure the cell...

 return cell;
 }
4

2 に答える 2

0

ストーリーボードで構成された静的テーブル ビューがあります。なんらかの動的データを入力していないため、以下の穴コード部分を削除しても問題ありません。

#pragma mark - Table view data source
于 2012-07-18T12:06:40.297 に答える
0

.xib ファイルから tableview のデータソースとデリゲートを設定しましたか? また、デリゲート cellForRowAtIndexPath にテキストを追加して、もう一度確認します。

于 2012-07-18T12:37:57.340 に答える