- (void)viewDidLoad {
[super viewDidLoad];
menuArray=[[NSMutableArray alloc]initWithObjects:@"Address",@"Restaurants",@"Deals",@"Orders",@"Account",@"Address Book",@"Settings",@"Live Chat",@"Info",nil];
tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, menuSubView.frame.size.height, self.view.frame.size.width-80, self.view.frame.size.height-menuSubView.frame.size.height)];
tableView.delegate=self;
tableView.dataSource=self;
[self.view addSubview:tableView];
}
とfollows-私はプログラムを実行するときしかし、私は必要に応じて、テーブルビューを見ることができていますfollows-
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return menuArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *[email protected]"Cell4";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reusableIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reusableIdentifier];
}
cell.textLabel.text=[menuArray objectAtIndex:indexPath.row];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 70;
}
などの他の方法として、プログラムでテーブルビューを作成しました。しかし、私はそれをスクロールすると、テーブルのデータが消えて、空白のテーブルビューだけが残っています。誰でも助けてくれますか?前もって感謝します。
がcellForRowAtIndexPathでブレークポイントを入れて、あなたがよくやったようだ –
をリロードした後、テーブルビューがどのように動作しているか、テーブルをスクロールした後に確認し、あなたのラベルの色は白ですか? –
cellForRowAtIndexPathにブレークポイントを置こうとしましたが、テーブルが完全に作成されるまでうまく動作します。一度テーブルをリロードすると、ポインタはcellForRowAtIndexPathに戻りません。 –