Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Need Help in Segue Creation

waqasarshadwaqasarshad Posts: 5New Users Noob
i am building a app for ios and i have a navbar button with will show user a uialertview with 2 buttons one for cancel and second one to to perform segue when user press cancel he will stay on the same page but when he press yas want to leave he will come to previous viewcontroller

here is the code of .m file
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello" message:@"Are You Sure??" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
    [alert show];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *BtnSelected = [alertView buttonTitleAtIndex:buttonIndex];
    if([BtnSelected isEqualToString:@"YES"]){
        [self performSegueWithIdentifier:@"perform" sender:self];

first when app load
<img src="/discussion/download/5590/iOS%2BSimulator%2BScreen%2Bshot%2BNov%2B7%2C%2B2013%2C%2B6.17.20%2BPM.png" />

when i press Button
<img src="/discussion/download/5591/iOS%2BSimulator%2BScreen%2Bshot%2BNov%2B7%2C%2B2013%2C%2B6.17.25%2BPM.png" />

when i press back
<img src="/discussion/download/5592/iOS%2BSimulator%2BScreen%2Bshot%2BNov%2B7%2C%2B2013%2C%2B6.17.31%2BPM.png" />

now if i press NO or YES nothing will happen :( please help.


  • waqasarshadwaqasarshad Posts: 5New Users Noob
  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    Your images did not load. You need to host them somewhere else and then include them inside BBCode [ img ] links.

    I've used IBAction code to trigger segues before. In order for that to work, you have to control-drag from your current VC to the target VC to create a segue, then name the segue with your identifier "perform", in this case.

    I would suggest not using the button title from the alert to decide what to do. That is fragile. What if you localize the app for other languages later?

    Instead, use the button index directly.

    To figure out what's going wrong, set a breakpoint at the first line of your alertView: clickedButtonAtIndex: method and step through it.
    Duncan C

    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • waqasarshadwaqasarshad Posts: 5New Users Noob
    ok thanks i will try this and get back. thanks again :)
Sign In or Register to comment.