初めて 2 番目のシーンを実装しようとしていますが、いくつかの問題があります。配列からのデータを使用して、テーブル ビューにセルのブロックを表示しようとしているだけです。私の最初のシーンと非常によく似たコードなので、なぜ機能しないのか戸惑っています。
コードは以下のとおりです。
#import "ChooseServerView.h"
#import "ViewController.h"
@interface ChooseServerView ()
@end
@implementation ChooseServerView;
@synthesize serverSelection;
- (void)viewDidLoad
{
serverSelection = [[NSArray alloc] initWithObjects:@"Chicgo, IL",@"London, UK",@"San Jose, CA",@"Washington, DC", nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark - Table View Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; // Default is 1 if not implemented
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; // fixed font style. use custom view (UILabel) if you want something different
{
if (section == 0) {
return @"Standard Test Locations:";
}
else {
return @"Quality Test Locations:";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
if (section == 0) {
return [serverSelection count];
}
else {
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *stdLocCell = nil;
stdLocCell = [tableView dequeueReusableCellWithIdentifier:@"serverSelection"];
if (stdLocCell == nil) {
stdLocCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"serverSelection"];
}
switch (indexPath.section) {
case 0:
stdLocCell.textLabel.text = [serverSelection objectAtIndex:indexPath.row];
break;
case 1:
stdLocCell.textLabel.text = @"Speed Test";
break;
default:
break;
}
return stdLocCell;
}
@end
セグエは期待どおりに機能し、ナビゲーションとタブバーは表示されますが、セルやデータは表示されず、空白です。
新しいシーンに移動すると、次のようなメモが出力に表示されます。
2013-01-03 13:08:34.878 MyConnection[15996:907] Interface Builder ファイル内の不明なクラス GLKView。
それがデータの不足と関係があるかどうかはわかりません。
新しいクラス コントローラーがストーリーボードの新しいシーンに接続され、以下に示すようにコンパイル命令に表示されます。