Saturday, 17 August 2013

UINavigationController in UITableViewCell

UINavigationController in UITableViewCell

I created a custom UITabelViewCell with property:
@property (nonatomic, strong) UINavigationController *navigationController;
Synthetized:
@syntethized navigationController = _navigationController
"Contructor":
+ (CustomCell *)cellForTableView:(UITableView *)tableView
navigationController:(UINavigationController *)navigationController {
CustomCell *cell = (CustomCell *)[tableView
dequeueReusableCellWithIdentifier:kCustomCellIdentifier];
if(cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"AddressCell" owner:self options:nil];
for (id currentObject in topLevelObjects)
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (CustomCell *) currentObject;
break;
}
}
cell.navigationController = navigationController;
return cell;
}
With method:
- (IBAction)viewMapAction:(id)sender {
MyViewController *controller = [[MyViewController alloc]
initWithNibName:@"MyViewController" bundle:nil];
[_navigationController pushViewController:controller animated:YES];
}
When I press the button inside my CustomCell, the navigation controller
push MyViewController normally. inside of MyViewController has a MKMapView
with an annotation, and in the viewDidAppar of MyViewController [_mapView
selectAnnotation:myAnnotation] has called, but a callout (popup) don't be
showed. If i press on annotation, callout don't be showed also.
Why?????
If change the constructor/property of my CustomCell and pass a
target/selector instead of UINavigationController, and create a
viewMapAction inside my UITableViewController instead of in my CustomCell,
the map callout appears normally. But I would centralized all cell action
inside cell class...

No comments:

Post a Comment