ios - How to use correctly segue with a Tab Bar Controller? -
my application use different master detail, consist in initial viewcontroller tableview, when user click add button in navigation controller need send object using follow function:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"adddgv"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; nsmanagedobject *object = [[self fetchedresultscontroller] objectatindexpath:indexpath]; [[segue destinationviewcontroller] setdetailview:object]; } }
the code works fine when destination viewcontroller, application designed have tabbarcontroller instead viewcontroller. tabbar have 2 tabs, each 1 different navigation controller, , first 1 target identifier "adddgv". created .m/.h files , associated class in storyboard, , set instance variable "detailview" id.
@property (strong, nonatomic) id detailitem;
the problem compiler don't know variable, because command [segue destinationviewcontroller]
contains view controller contents should displayed @ end of segue. end of segue tabbarcontroller, function doesn't work.
someone knows how fix it???
typecast output of
[segue destinationviewcontroller]
as follows
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"adddgv"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; nsmanagedobject *object = [[self fetchedresultscontroller] objectatindexpath:indexpath]; [(yourdestinationviewcontroller *)[segue destinationviewcontroller] setdetailview:object]; } }
Comments
Post a Comment