我有一个带有 UITableView 控件的简单表视图控制器。我已经在我的头文件中实现了 UITableViewDelegate 和 UITableViewDatasource 。我已将数据源和委托指定为包含 UITableView 的 ViewController。但是,没有一个表视图方法被触发。我已经发布了精简的源代码和显示委托/数据源的屏幕截图。为什么事件没有连接的可能原因是什么?
(仪表是一个包含值对象的 NSArray 的模型)
标题
#import <UIKit/UIKit.h>
#import "GaugeList.h"
@interface SitePickerViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic,strong) GaugeList *gauges;
@end
执行
#import "SitePickerViewController.h"
@interface SitePickerViewController ()
@end
@implementation SitePickerViewController
@synthesize gauges;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSInteger rowCount = [gauges.gaugeList count];
NSLog(@"numberOfRowsInSection called: %i\n", rowCount);
return rowCount;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"cellForRowAtIndexPath\n");
UITableViewCell *cell = [[UITableViewCell alloc] init];
return cell;
}
-(void)loadView{
gauges = [[GaugeList alloc] initWithStateIdentifier:@"WV" andType:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"viewDidLoad called: %i\n", [gauges.gaugeList count]);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end