プロが教える店舗&オフィスのセキュリティ対策術

こんにちは。
iPhoneアプリの勉強している者ですが、TableViewControllerを使いセルごとに名前を表示させようとしているのですが、タイトルのみが表示されて肝心のセル名が表示されません。
appDelegate.mにてUINavigationControllerのインスタンス及びUITableViewControllerのインスタンスを作成してUITableViewControllerのインスタンスをrootViewControllerに設定しTableViewを表示させようとしています。
プログラムの記述のどこが間違っているのか教えて頂けると大変助かります。

以下UITableViewControllerのinterfaceセクションとimplementationセクションを掲載しますので、ご指摘お願いします。

#import <UIKit/UIKit.h>

@interface SampleForSimpleTable : UITableViewController
{
NSArray *itemes;
}

@end

@implementation SampleForSimpleTable

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"SimpleTable";
itemes = [[NSArray alloc] initWithObjects:@"ITME 1", @"ITEM 2", @"ITEM 3", @"ITEM 4", @"ITEM 5", @"ITEM 6", nil];

}



#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 [itemes count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"default-cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier ];
if (!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.text = [itemes objectAtIndex:indexPath.row];
// Configure the cell...

return cell;
}

A 回答 (1件)

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView


{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0; // セクションがないという意味。
}

返り値が0ではいけません。最低でも1以上でないと。
「#warning」に、テンプレートのままでは、不完全なメソッドの実装になると、書かれていますね?
    • good
    • 0
この回答へのお礼

回答ありがとうございます。
見落としてました。
きっちり、コードみないとだめですね。

お礼日時:2014/09/07 23:47

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!