我正在尝试使用iOS构建应用程序。我正在使用Xcode 6.4,the tutorial I was following似乎接受使用fun和override,但是当我尝试它时,它会带来错误。我正在将受保护的页面连接到我的注册页面。
#import "ViewController.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.
- (void)ViewDidAppear(animated: bool) {
[self.PerformSegueWithIdentifier("LoginView", sender: self)];
}
}
@end
有人可以帮我指出我的错误和解决方案吗?
答案 0 :(得分:4)
欢迎来到SO。通常这不是一般的调试服务,但你可能想要一脚......
PerformSegueWithIdentifier
与performSegueWithIdentifier
所以你要做的正确版本是......
@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.
}
- (void)viewDidAppear:(BOOL)animated {
[self performSegueWithIdentifier:@"LoginView" sender:self];
}
@end
玩得开心,享受iOS开发。
答案 1 :(得分:3)
您无法在另一个方法定义中插入
在我看来,你在某种程度上搞砸了Swift和Objective C代码, 您的代码应如下所示:
@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.
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSegueWithIdentifier:@"LoginView" sender:self];
}
@end
答案 2 :(得分:-3)
看起来你只是试图覆盖viewcontrollers viewDidAppear方法。如果是这种情况,那么该方法位于错误的位置(在您的代码中,它的嵌套在didReceiveMemoryWarning中
试试这个:
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL) animated {
[super viewDidAppear:animated];
[self.performSegueWithIdentifier("nameOfSeque", sender: self)];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end