Ios UITable不调用委托方法
我有一个UIView,我在其中初始化一个表并将UIView设置为它的委托。我的.h文件:Ios UITable不调用委托方法,ios,uitableview,Ios,Uitableview,我有一个UIView,我在其中初始化一个表并将UIView设置为它的委托。我的.h文件: ... @interface vOperatingRooms : UIView <UITableViewDataSource, UITableViewDelegate>{ ... 另一种方法是从plist读取数据以构建表的数据源: ... //set up the directory path NSString* pathToProjectFolder = [NSString
...
@interface vOperatingRooms : UIView <UITableViewDataSource, UITableViewDelegate>{
...
另一种方法是从plist读取数据以构建表的数据源:
...
//set up the directory path
NSString* pathToProjectFolder = [NSString stringWithFormat:@"Projects/%@", projectNumber];
//set up the file path
NSString* ORDataFilePath = [NSString stringWithFormat:@"%@/ORData.plist", pathToProjectFolder];
//check to make sure the project directory exists and the ORData.plist file
[fileManager createDirectory:pathToProjectFolder];
[fileManager createPlist:ORDataFilePath];
//pull the data from the file
NSDictionary* ORData = [fileManager readPlist:ORDataFilePath];
ORNames = [[NSMutableArray alloc] init];
for(NSString* thisOR in ORData){
if (![thisOR isEqualToString:@"File Name"]) {
[ORNames addObject:thisOR];
}
}
//fade in table
//fade in
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
dataTable.alpha = 1.0;
}
completion:^ (BOOL finished) {
}
];
...
我已经记录了结果,我正在获取我正在寻找的数据-这是NSArray ORNames的控制台:
2012-12-06 15:01:23.370 IntegrationSiteReport[18697:c07] (
Test4,
Test6
)
以下是委托方法:
#pragma mark Table View Management
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return ORNames.count;
NSLog(@"%i", ORNames.count);
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [ORNames objectAtIndex:indexPath.row];
cell.textLabel.textColor = [colorManager setColor:66.0 :66.0 :66.0];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:20.0];
return cell;
}
我知道他们不会被呼叫,因为他们内部没有任何日志记录。这里有我遗漏的东西吗?什么时候叫showSelf?如果是在视图加载继承人权限之后,您可能只需要添加一个
[dataTable reloadData]代码>作为showSelf的最后一行,但不确定。什么时候调用showSelf?如果是在视图加载继承人权限之后,您可能只需要添加一个[dataTable reloadData]代码>作为showSelf的最后一行,但对此并不确定。关于我的评论是如何被删除的,我在发布后就发现了这一点(典型)。但无论如何,我会给你胜利的谢谢你!这对我很有帮助。我的一些评论是如何被删除的,我在发布后就发现了这一点(典型)。但无论如何,我会给你胜利的谢谢你!这对我有帮助。
#pragma mark Table View Management
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return ORNames.count;
NSLog(@"%i", ORNames.count);
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [ORNames objectAtIndex:indexPath.row];
cell.textLabel.textColor = [colorManager setColor:66.0 :66.0 :66.0];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:20.0];
return cell;
}