I have created the button in the viewdidload method:
UIButton * button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 addTarget:self action:@selector(showVideo:)forControlEvents:UIControlEventTouchUpInside];
In button action method i called the segue programatically:
- (void) showVideo:(id)sender {
[self performSegueWithIdentifier: @"MySegue" sender: self];
}
In prepare for segue method the code to call the modal view controller
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"MySegue"])
{
Xen_VideoViewController *addController = [segue destinationViewController];
[self presentViewController:addController animated:YES completion: nil];
}
}
i referred the link [link]:Creating a segue programmatically
but i am getting the error as
"Application tried to present modally an active controller"
i need to show the modal view controller when the button pressed but the button was created programatically. the button was repeated in the scroll view.
Any other method to get the modal view controller?
Thanks in advance….