我正在尝试从 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]; }
}
在我的 .h 文件中,我有一个 UINavigatoinDelegate 集
@interface CRHScripting : UIViewController <UITextViewDelegate,UINavigationControllerDelegate>
在情节提要中,我将视图控制器的标识符设置为 firstView。
线
[self.navigationController modalViewController:firstView animated:YES];
给我带来了所有的麻烦。错误说
"No visible @interface for 'UINavigationController' declares the selector 'modalViewController:animated:'
这是什么意思?
更新:现在我的视图不会完全加载,但它会显示视图控制器
这是我的初始化代码:
#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