我想從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