我是 Objective c 编程的新手,我正在制作一个应用程序。我正在使用 osx 10.8.4 和 xcode 4.6。我试图在单视图应用程序中(模态)从一个视图控制器到另一个视图控制器。我已经给出了segue 的segue 标识符并在storyboard 中放置了一个segue。但是,当我尝试 segue 时,控制台会显示:
Warning: Attempt to present <UIViewController: 0x74acff0> on <ViewController: 0x82b25a0> whose view is not in the window hierarchy!
这是我的第一个视图控制器 .m 文件的代码(包含要转义的代码):
Viewcontroller.m:
#import "ViewController.h"
#import "hackScreen.h"
#import "AppDelegate.h"
#import <RevMobAds/RevMobAds.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)hackStarter:(id)sender {
NSString *checker = [_redBoulderRepublic text];
int soLong = [checker length];
UIAlertView *wrongNumber = [[UIAlertView alloc]
initWithTitle:@"Invalid number"
message:@"Please enter a valid phone number"
delegate:nil
cancelButtonTitle:@"dismiss"
otherButtonTitles:nil];
if (soLong == 10){
[self performSegueWithIdentifier:@"SegueOne" sender:sender];
}
else{
[wrongNumber show];
}
}
- (void)dealloc {
[_redBoulderRepublic release];
[super dealloc];
}
- (IBAction)keyboardKiller:(id)sender {
[_redBoulderRepublic resignFirstResponder];
}
@end
还有我的 .h 文件:
Viewcontroller.h:
#import <UIKit/UIKit.h>
#import <RevMobAds/RevMobAds.h>
#import "AppDelegate.h"
#import "hackScreen.h"
@interface ViewController : UIViewController
- (IBAction)hackStarter:(id)sender;
@property (retain, nonatomic) IBOutlet UITextField *redBoulderRepublic;
- (IBAction)keyboardKiller:(id)sender;
@end