我想从UIAlertView模式到视图控制器。不能从UIAlertView更改viewcontroller
- (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:'
这是什么意思?
更新:现在我查看wont't完全加载,但它会显示视图控制器
这里是我的初始化代码:
#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
工作,但是当它模式化到视图控制器它会出现黑暗,我不能做任何事情。就像它没有启用或什么的。 – Craig
您的新视图控制器加载是否成功?你可以在viewDidLoad中验证它吗? – ohr
未成功加载。 – Craig