我的情况:
- 我已经在情节提要中获得
datasource
并连接delegate
- 我有我的
UITableViewCell
和标识符以及定义的代码等。 - 我有我的
array
数据UITableView
,在调试中我的数据array
填充viewDidload
方法
所以一切似乎都是正确的,直到我到达cellForRowIndexPath
and numberOfRowsInSection
。它没有进入方法。当我进一步运行时,调试完成,没有任何故障,只有黑色
UITableView
我什么都没有。真的很奇怪,因为我的数组充满了数据,一切都按照应有的方式连接。
需要一些帮助,我现在正在寻找几天!
如果需要代码来帮助,问我。
我的代码:
m.文件:
#import "DagprogrammaDetailViewController.h"
@interface DagprogrammaDetailViewController ()
@end
@implementation DagprogrammaDetailViewController
{
NSMutableArray *DagprogrammaDetail;
}
@synthesize menuNaam;
@synthesize tableDagprogrammaDetail;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = menuNaam;
NSArray *dagarray = [menuNaam componentsSeparatedByString:@" "];
NSString *plaatsString = [dagarray objectAtIndex:1];
plaatsString = [plaatsString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
//object ophalen
NSMutableString *urlString = [NSMutableString stringWithFormat:@"http://zesdaagse.mobi-app.be/WCFUrl/MobileService.svc/GetDagprogramma"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSMutableArray *id = [NSMutableArray array];
for(NSDictionary *item in json)
{
[id addObject:[item objectForKey:@"id"]];
}
int plaats = [plaatsString intValue];
plaats -= 1;
//id van de dag ophalen
NSString *idDagprogramma = [id objectAtIndex:plaats];
urlString = [NSMutableString stringWithFormat:@"http://zesdaagse.mobi-app.be/WCFUrl/MobileService.svc/GetDagprogrammaWedstrijden?id="];
[urlString appendString:[NSString stringWithFormat:@"%@",idDagprogramma]];
url = [NSURL URLWithString:urlString];
data = [NSData dataWithContentsOfURL:url];
json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSMutableArray *idWedstrijdDagprogramma = [NSMutableArray array];
NSMutableArray *naam = [NSMutableArray array];
NSMutableArray *uur = [NSMutableArray array];
for(NSDictionary *item in json)
{
[idWedstrijdDagprogramma addObject:[item objectForKey:@"id"]];
[naam addObject:[item objectForKey:@"naam"]];
[uur addObject:[item objectForKey:@"uur"]];
}
DagprogrammaDetail = [NSMutableArray arrayWithObjects: nil];
for(int i = 0; i < json.count; i ++)
{
NSMutableString *lijn =[NSMutableString stringWithFormat:@"%@", [naam objectAtIndex:i]];
[lijn appendString:[NSMutableString stringWithFormat:@"%s", "\t \t"]];
[lijn appendString:[NSMutableString stringWithFormat:@"%@", [uur objectAtIndex:i]]];
[DagprogrammaDetail addObject:lijn];
}
}
//methode om aantal items te weten van de array
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [DagprogrammaDetail count];
}
//methode om een item aan een index te koppelen en zichtbaar te maken
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"MenuDetailCell";
UITableViewCell *cell = [self.tableDagprogrammaDetail dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.numberOfLines = 1;
cell.textLabel.text = [DagprogrammaDetail objectAtIndex:indexPath.row];
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end