【发布时间】:2013-01-03 15:53:12
【问题描述】:
我第一次尝试实现第二个场景,但遇到了一些问题。只需尝试在表格视图中显示包含数组数据的单元格块。与我的第一个场景非常相似的代码,这就是为什么我对它为什么不起作用感到困惑。
代码如下:
#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
segue 按预期工作,导航和标签栏出现,但没有单元格或数据,只是空白。
移动到新场景时,输出中有一条注释:
2013-01-03 13:08:34.878 MyConnection[15996:907] 未知类 GLKView 在 Interface Builder 文件中。
不确定这是否与缺少数据有关。
New Class 控制器连接到情节提要上的新场景,并出现在编译指令中,如下所示:
【问题讨论】:
-
您确定已将 GLKView 正确添加到默认目标中吗? stackoverflow.com/questions/1725881/…
-
@SpaceDust 我不确定我要查看的帖子的确切位置?
-
Using XCode 4, in the Project Navigator, select the .m file that contains the class that it is complaining about转到查看->实用程序->显示文件检查器(这将在右侧显示文件检查器,带有 .m 文件信息)Open the Target Membership section and make sure that your target is selected for this .m-file -
@SpaceDust 我曾假设这是该部分,并且可以验证是否选择了目标。我什至没有检查,运行程序并再次检查,因为一篇帖子建议无济于事。我看不到 GLKView 类在哪里,因为我没有使用它,这让我很困惑。是这个错误导致表格视图无法显示吗?
-
您的代码似乎没有问题,我建议您在上面的链接上关注并应用每个不同的答案,因为 GLK View 是一类 OpenGLES 框架,您收到该警告确实没有意义。
标签: ios objective-c xcode storyboard tableview