我的应用中有一个表格视图。如果我在加载之前显示我的插页式广告,则会填充表格,否则如果我想在插页式广告后进行展示,则表格视图为空。
我进行了调试,我看到了:如果显示插页式广告,然后我想查看我的表格视图,则永远不会调用方法numberOfRowsInSection。
这是我的代码:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
//End recieving events
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (void)viewDidLoad
{
[super viewDidLoad];
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"nav64.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIColor whiteColor],NSBackgroundColorAttributeName,nil];
self.navigationController.navigationBar.titleTextAttributes = textAttributes;
NSDate *date = [NSDate date];
NSDateFormatter* emmformatter = [[NSDateFormatter alloc] init];
[emmformatter setDateFormat:@"MM"];
NSDateFormatter* eddformatter = [[NSDateFormatter alloc] init];
[eddformatter setDateFormat:@"dd"];
NSDateFormatter* eyyyyformatter = [[NSDateFormatter alloc] init];
[eyyyyformatter setDateFormat:@"yyyy"];
NSDateFormatter* ehhformatter = [[NSDateFormatter alloc] init];
[ehhformatter setDateFormat:@"HH"];
NSString * mmz= [emmformatter stringFromDate:date];
NSString * jjz= [eddformatter stringFromDate:date];
NSString * yyyyz= [eyyyyformatter stringFromDate:date];
NSString * hhz= [ehhformatter stringFromDate:date];
// NSLog(@"%@",[NSString stringWithFormat:@"epg_cache/programme-tv-rss_%@-%@-%@.xml",yyyyz,mmz,jjz]);
NSURL *url = [NSURL URLWithString:@"http://theambassador.fr/"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
[httpClient postPath:@"tvlive/Bresil_20141105_150122.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
resultofData = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
test=[resultofData valueForKey:@"name"];
self.categoryArray=[resultofData valueForKey:@"category"];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[[[UIAlertView alloc]initWithTitle:@":( " message:@"Pas d'internet !" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]show];
}];
NSString *titleapp = @"Programma de TV";
self.navigationItem.title = titleapp;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [test count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 65.0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
ChaineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"chiancelelidentif"];
cell.title.text=[test objectAtIndex:indexPath.row];
//cell.title.text = [[[globarr objectAtIndex:indexPath.row]objectAtIndex:0]objectForKey:@"nomchaine"];
NSDictionary *midic = [resultofData objectAtIndex:indexPath.row];
[cell.imag setImageWithURL:[NSURL URLWithString:[midic objectForKey:@"image"]]];
return cell;
}