Reputation: 2575
I'm trying to create a table on WatchKit. For some reason the app is just blank when launched in WatchKit. I've confirmed that it's a table problem (I added a static label and was able to see it). I believe I have all IBOutlets hooked up properly as well. What am I doing wrong?
I have the following code on my InterfaceController.h:
@interface InterfaceController : WKInterfaceController {
NSMutableArray *listArray;
}
@property (weak, nonatomic) IBOutlet WKInterfaceTable *playlistTable;
InterfaceController.m:
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
// Configure interface objects here.
listArray = [[NSMutableArray alloc] initWithObjects:@"Hello", @"Watch", @"World", nil];
[self setupTable];
}
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
}
- (void)didDeactivate {
// This method is called when watch view controller is no longer visible
[super didDeactivate];
}
- (void)setupTable {
[self.playlistTable setRowTypes:listArray];
for (int i = 0; i < self.playlistTable.numberOfRows; i++)
{
universalRow *row = [self.playlistTable rowControllerAtIndex:i];
[row.mainTitle setText:[listArray objectAtIndex:i]];
[row.subtitleLabel setText:@"subtitle!"];
}
}
and NSObject row class 'universalRow':
@interface universalRow : NSObject {
}
@property (nonatomic, weak) IBOutlet WKInterfaceLabel *mainTitle;
@property (nonatomic, weak) IBOutlet WKInterfaceLabel *subtitleLabel;
@end
Upvotes: 1
Views: 252
Reputation: 2575
It turns out I didn't set my Row Controllers' identifier in the storyboard. Once I did that, it worked as intended.
Upvotes: 1
Reputation: 9825
setRowTypes:
takes an array of strings that are each names you assigned to your row controllers in the storyboard, not the data you are going to put in the row.
You probably want [self.playlistTable setNumberOfRows:listArray.count withRowType:@"RowType"]
where @"RowType"
is whatever name you gave to your row controller in the storyboard.
Upvotes: 1