Kre*_*erg 5 objective-c ios watchkit wkinterfacetable
我正在尝试设置WKInterfaceTable.我跟着苹果文档.我的标签没有获取文本,我在控制台中收到此错误消息:
Cannot specify setter 'setTitle:' for properties of NSObject or WKInterfaceController
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?Objective-C拜托.这是我的代码:
.H
#import <Foundation/Foundation.h>
#import <WatchKit/WatchKit.h>
@interface MainRowType : NSObject
@property (strong, nonatomic) IBOutlet WKInterfaceImage *image;
@property (strong, nonatomic) IBOutlet WKInterfaceLabel *title;
@end
Run Code Online (Sandbox Code Playgroud)
.M
#import "MainRowType.h"
@implementation MainRowType
@end
Run Code Online (Sandbox Code Playgroud)
.H
#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import "MainRowType.h"
@interface WatchTableController : WKInterfaceController
@property (strong, nonatomic) IBOutlet WKInterfaceTable *tableView;
@property (strong, nonatomic) NSMutableArray *titleArray;
@end
Run Code Online (Sandbox Code Playgroud)
.M
我称这种方法
- (void)configureTableWithData:(NSMutableArray*)dataObjects {
[self.tableView setNumberOfRows:[dataObjects count] withRowType:@"mainRowType"];
for (NSInteger i = 0; i < self.tableView.numberOfRows; i++) {
MainRowType* theRow = [self.tableView rowControllerAtIndex:i];
NSString *titleString = [dataObjects objectAtIndex:i];
[theRow.title setText:titleString];
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
538 次 |
| 最近记录: |