lundi 1 décembre 2014

IOS Segue is not working in Custom Tab bar

i make my custom tab bar using segue it's run successfully , now i try to pass data between two view controller which is on tab bar view controller , i took total 4 view controller for custom tab bar view controller.but i am not getting button click event on this 4 view controller for open new view controller OR passing data between this 4 view controller.


my code for tab bar controller



- (void) perform {

ViewController *ctbcv = (ViewController *)self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
for(UIView *view in ctbcv.placeholder.subviews)
{
[view removeFromSuperview];
}
ctbcv.currentViewController = dst;
[ctbcv.placeholder addSubview:dst.view];
}


and segue condition



-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"HomeSegue"]
|| [segue.identifier isEqualToString:@"DeveloperSegue"]
|| [segue.identifier isEqualToString:@"DesignerSegue"]|| [segue.identifier isEqualToString:@"btn4"]){

NSLog(@"%lu",(unsigned long)[self.buttons.subviews count]);

for (int i=0; i<[self.buttons.subviews count];i++) {
UIButton *button = (UIButton *)[self.buttons.subviews objectAtIndex:i];
[button setSelected:NO];
}

UIButton *button = (UIButton *)sender;
NSLog(@"%ld", (long)button.tag);
btnclicked = button.tag;
[button setSelected:YES];
}
}


this code run successfully, now i create button on 1st view controller and give segue to the new view controller , it's crash when click on button.



- (void)viewDidLoad {
[super viewDidLoad];

[btnnext addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];

}

-(void) buttonClicked:(UIButton*)sender
{

NSLog(@"you clicked on button %ld", (long)sender.tag);

[self performSegueWithIdentifier:@"MySegue" sender:sender];

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"MySegue"]) {
navVC *vc = [segue destinationViewController];

}
}


After this code it crash and Xcode show "THREAD 1: EXC_BAD_ACCESS(code=2 , address = 0xc)" any solution ?


i use this reference for making custom tab bar = http://ift.tt/1r2r7XX


i make button which open new view controller in this tab bar.


Thank You




Aucun commentaire:

Enregistrer un commentaire