I am trying to modal to a view controller from a UIAlertView.
- (IBAction)cancelScripting:(id)sender {
UIAlertView *areYouSure = [[UIAlertView alloc]initWithTitle:@"Are You Sure?" message:@"Are you sure you want to quit scripting?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[areYouSure show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
CRHViewController *firstView = [[CRHViewController alloc] init];
[self.navigationController modalViewController:firstView animated:YES]; }
}
In my .h file I have a UINavigatoinDelegate set
@interface CRHScripting : UIViewController <UITextViewDelegate,UINavigationControllerDelegate>
In storyboard I have my view controller’s identifier set to firstView.
The line
[self.navigationController modalViewController:firstView animated:YES];
is giving me all the trouble. The error says
"No visible @interface for 'UINavigationController' declares the selector 'modalViewController:animated:'
What does this mean?
Update: Now My View wont’t fully load, but it will show the view controller
Here is my init code:
#import "CRHViewController.h"
@interface CRHViewController ()
@end
@implementation CRHViewController
-(void)updateTimer {
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"h:mm"];
clockLabel.text = [format stringFromDate:[NSDate date]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];
[homeIconScrollView setScrollEnabled:YES];
[homeIconScrollView setContentSize:CGSizeMake (150,1100)];
NSLog(@"Did Load first View");
}
- (void)viewDidAppear:(BOOL)animated {
[UIImageView beginAnimations:NULL context:nil];
[UIImageView setAnimationDuration:2];
[scrollNotify setAlpha:0];
[UIImageView commitAnimations];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIDeviceOrientationLandscapeRight);
}
@end
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completionis a UIViewController method not a UINavigationController method. The correct line is:*Note that
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animatednow shows as being deprecated. If you still want to use it: