我正在使用LeveyPopListView。 LeveyPopList View内部是一个包含特定公司中的作业的表。一切都很好,直到我在弹出列表视图中点击一个工作,我已经检查了一切。 这是我的代码:
NSArray* ar_filter=(NSArray*)[self.FilterDictionary objectForKey:@"sub_slots"];
NSInteger numberOfJobs = [[[[[self.FilterDictionary objectForKey:@"sub_slots"] valueForKey:@"company_group"] valueForKey:@"job_count"] objectAtIndex:[self.jobsTableView indexPathForSelectedRow].row] intValue];
NSLog(@"NUMBER OF JOBS: %ld", (long)numberOfJobs);
NSLog(@"ARRAY FILTER: %@", ar_filter);
//MARK: for consolidated view
if([[ar_filter objectAtIndex:[self.jobsTableView indexPathForSelectedRow].row] objectForKey:@"company_group"])
{
if(numberOfJobs > 1)
{
NSString *company_id = [[[[self.FilterDictionary objectForKey:@"sub_slots"] valueForKey:@"company_group"] valueForKey:@"company_id"] objectAtIndex:[self.jobsTableView indexPathForSelectedRow].row];
NSString *company_name = [[[[self.FilterDictionary objectForKey:@"sub_slots"] valueForKey:@"company_group"] valueForKey:@"company_name"] objectAtIndex:[self.jobsTableView indexPathForSelectedRow].row];
NSDictionary *specificCompany = [NSDictionary dictionaryWithObjectsAndKeys:company_id,@"company_id", nil];
if(specificCompany.count>0)
{
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:specificCompany
options:0
error:&error];
if (! jsonData)
{
NSLog(@"Got an error: %@", error);
}
else
{
strJsonStringFilter = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
allJobsDictionary = [NSJSONSerialization JSONObjectWithData:[network getData:[NSString stringWithFormat:@"get_all_job_offers?pt_id=%@&filter=%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"pt_id"], strJsonStringFilter]] options:kNilOptions error:nil];
//this contains the jobs that are given by allJobsDictionary
jobsToDisplay=(NSArray*)[allJobsDictionary objectForKey:@"sub_slots"];
//call LeveyPopListView
LeveyPopListView *lplv = [[LeveyPopListView alloc] initWithTitle:company_name options:jobsToDisplay handler:^(NSInteger anIndex)
{
}];
lplv.delegate = self;
[lplv showInView:self.view animated:YES];
strJsonStringFilter = @"";
}
}
- (void)leveyPopListView:(LeveyPopListView *)popListView didSelectedIndex:(NSInteger)anIndex {
NSDictionary *job = (NSDictionary*)[jobsToDisplay objectAtIndex:anIndex];
// Pass data and transit to detail job view controller
[self.parentViewController performSelector:@selector(showJobDetailWith:) withObject:job];
}
-(void)showJobDetailWith:(NSDictionary *)dictionary {
// Pass data to global variable for prepareForSegue method
mapPinSelectedDictionary = dictionary;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MTJobDetailTableViewController *smsController=[storyboard instantiateViewControllerWithIdentifier:@"MTJobDetailTableViewController"];
[smsController setJobDetailDict:mapPinSelectedDictionary];
[self.navigationController pushViewController:smsController animated:YES];
}
来自 LeveyPopListVIew.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// tell the delegate the selection
if ([_delegate respondsToSelector:@selector(leveyPopListView:didSelectedIndex:)])
[_delegate leveyPopListView:self didSelectedIndex:[indexPath row]];
if (_handlerBlock)
_handlerBlock(indexPath.row);
// dismiss self
[self fadeOut];
}
当这行代码时,应用程序崩溃了:
[self.parentViewController performSelector:@selector(showJobDetailWith:) withObject:job];
被调用。任何人都可以帮助我。谢谢。
答案 0 :(得分:1)
试试这个
- (void)leveyPopListView:(LeveyPopListView *)popListView didSelectedIndex:(NSInteger)anIndex {
NSDictionary *job = (NSDictionary*)[jobsToDisplay objectAtIndex:anIndex];
// Pass data and transit to detail job view controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MTJobDetailTableViewController *smsController=[storyboard instantiateViewControllerWithIdentifier:@"MTJobDetailTableViewController"];
[smsController setJobDetailDict: job];
[self.navigationController pushViewController:smsController animated:YES];
}