我正在使用iOS SDK 8.3并尝试按照本教程在手表套件应用程序中创建一个表。
我在 iWatch 应用程序的界面控制器上添加了一个表,然后将其链接到我的 InterfaceController。我创建了一个自定义行类并将该行链接到行控制器类。然后我在行中添加了几个项目并将它们链接到行控制器类中的插座。但是我得到一些错误:
这是我的接口控制器类:
#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
@interface InterfaceController : WKInterfaceController
@property (strong, nonatomic) NSArray *devicesArray;
@property (weak, nonatomic) IBOutlet WKInterfaceGroup *devicesTable;
@end
这是触发错误的代码:
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
NSLog(@"%@ initWithContext", self);
self.devicesArray = @[@"type A", @"type B"];
[self.devicesTable setNumberOfRows:self.devicesArray.count withRowType:@"MyTableRowController"];
[self.devicesTable enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
MyTableRowController* row = [self.devicesTable rowControllerAtIndex:idx];
[row.deviceType setText: (NSString*)obj];
[row.logo setImage:[UIImage imageNamed:(NSString *)obj]];
}];