0

以下代码不适合我。每当调用该方法时,应用程序就会崩溃我做错了什么?

此代码确实使用情节提要格式

在 .h 文件中

@class SendVideoViewController;

...

@property (nonatomic) SendVideoViewController *sendVideoViewController;

在 .m 文件中

#import "SendVideoViewController.h"
...
@synthesize sendVideoViewController;
...
- (IBAction)signMeUpButtonPressed:(id)sender {
termsAndConditionsViewController = [[TermsAndConditionsViewController alloc] init];
[self presentViewController:termsAndConditionsViewController animated:YES completion:nil];
//[self.view insertSubview:termsAndConditionsViewController.view atIndex:0];
}
4

2 回答 2

2

您的代码应为:

sendVideoViewController = [[SendVideoViewController alloc] init];
[self presentViewController:sendVideoViewController animated:YES completion:nil];

现在您正在实例化一个泛型UIViewController类。为了创建您在SendVideoViewController类中定义的类型的对象,您需要调用+alloc该类,而不是UIViewController. 您可能想复习一下文档

于 2012-12-11T03:12:23.583 回答
0

试试这个:

sendVideoViewController = [[SendVideoViewController alloc] init];
[self presentViewController:sendVideoViewController animated:YES completion:nil];
于 2012-12-11T04:01:13.870 回答