私はビューベースのアプリケーションを1つだけ持っています:TableViewに配列を表示しますが、動作しません。理由はわかりません。ここにコードがあります。UITableViewにテキストを表示できません
.h
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>{
NSArray *array;
IBOutlet UITableView *table;
}
.m
-(void)viewDidLoad{
[super viewDidLoad];
array = [array initWithObjects:@"iPad", @"iTV", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
return cell;
}
なぜTableViewにテキストが表示されないのですか?ありがとう、人々! NSIndexPathは "行" プロパティを持っていない
ARCの下
をリリースし、それを保持するか、またはしたい場合に応じて、
または
のいずれかである必要があり指摘しています'メソッドと呼ばれる? – barley
申し訳ありませんが、viewDidLoadにありました。私はそれを編集するつもりです。 – Adri