Open raster view manually

I have an application using Storyboard. There is an AlertViewDialog in appearance.

When the user clicks on the first button ("Yes"), how can I open another view on the storyboard?

+6
source share
3 answers

My this will help:

  • Drag the view, then go to Identity Inspector (shortcut: option + apple + 3).
  • Select the recently dragged view and specify a unique name from the inspector ID in the header of the storyboard identifier. // see image for reference enter image description here

subclass the ViewView class (.h & .m) of the SecondViewController class for the viewController.

then from the alert viewing code (as you said when the "Yes" button is clicked)

paste the code below

SecondViewController *svc =[self.storyboard instantiateViewControllerWithIdentifier:@"vinay"]; [svc setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; [self presentViewController:svc animated:YES completion:nil]; 

let me know if there are any problems.

+10
source

This will help:

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ClassNameViewController *viewController = (ClassNameViewController *)[storyboard instantiateViewControllerWithIdentifier:@"viewIdentifierOnStoryboard"]; [self presentModalViewController:viewController animated:NO]; 
+5
source

The first thing you need to do is set the UIAlertView delegate to do this add the UIAlertViewDelegate to your @interface so that it looks like

  @interface myClass : super <UIAlertViewDelegate> // super could be anything like `UIViewController`, etc @end 

and in @implementation you can add something like

  @implementation myClass ........... Some code - (IBAction)someActionMethod:(id)sender { UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:nil message:@"Would you like to move on?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [myAlertView show]; // [myAlertView release]; Only if you aren't using ARC } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { switch(buttonIndex) { case 1: SecondViewController *svc =[self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"]; [svc setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; // [self presentViewController:svc animated:YES]; // Deprecated in iOS 6.0 [self presentViewController:svc animated:YES completion:nil]; // Introduced in iOS 5.0 break; default: break; } } @end 

Remember to set a unique identifier in the storyboard. You can do this by going to your .storyboard and in the Identity Inspector (selecting the third one), you can set the Storyboard ID , this is what you will need to match with what is in instantiateViewControllerWithIdentifier , so in the above case it will be "secondViewController" It's simple.

Remember to close this view when you are done, you will need to use

  [self dismissModalViewControllerAnimated:YES]; 

The above is really deprecated in iOS 6.0, but you can use

  [self dismissModalViewControllerAnimated:YES completion:nil]; 

What does the same, except for it, adds a completion block to the end.

Hope this helps.

0
source

All Articles