0

ストーリーボード: http://s7.directupload.net/images/140717/z5hwmezv.png

フォルダの代わりにファイルをトリガーするまで、同じテーブルビュー コントローラー (ファイルとフォルダーがあるとしましょう) を再帰的にトリガーするアプリがあります。ファイルをクリックすると、GLKit View Controller にジャンプします。

今、プログラムでtableViewのサイズを変更したいのですが、うまくいきません。ウィンドウのサイズは既に取得しています。これを使用して、tableView の位置とサイズを計算します。

CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;

次のようにサイズを変更するさまざまな方法を試しましたが、何も変わりません。

mainTableView.frame = CGRectMake(0, 0, screenWidth, screenHeight);

プログラムでmainTableViewを作成すると機能しますが、セグエが削除され、プログラムでセグエを作成する解決策が見つかりませんでした。

ストーリーボードの tableView で動作するソリューションを見つけるのを手伝っていただければ幸いです。

4

2 に答える 2

0

ステップ 1: デリゲート UITableViewDataSource、UITableViewDelegate を追加する

@interface viewController: UIViewController<UITableViewDataSource,UITableViewDelegate>
{
   UITableView *tableView;
}

ステップ2:

-(void)viewDidLoad
{
tableView=[[UITableView alloc]init];
tableView.frame = CGRectMake(10,30,320,400);
tableView.dataSource=self;
tableView.delegate=self;
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[tableView reloadData];
[self.view addSubview:tableView];

}

ステップ 3: tableview のプロパティ

//-- For table sections

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return 1;
}

//-- For no of rows in table

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

//-- Table header height if needed

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
   return 50;
}

//-- Assign data to cells

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

   if (cell == nil)
   {
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
   }
   cell.textLabel.text=[your_array objectAtIndex:indexPath.row]; ***(or)*** cell.textLabel.text = @"Hello";
   return cell;
}

//-- Operation when touch cells

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   // Your custom operation
}
于 2014-07-17T22:30:44.070 に答える