我正在按照ios教程将Facebook集成到我的应用程序中。一切顺利,直到我开始讨论添加注销按钮。我不断收到错误消息,指出在类型的对象上找不到属性“ViewController”。我究竟做错了什么?这是我的appdelegate.m文件中的代码。
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add the requests dialog button
UIButton *requestDialogButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
requestDialogButton.frame = CGRectMake(40, 150, 200, 40);
[requestDialogButton setTitle:@"Send Request" forState:UIControlStateNormal];
[requestDialogButton addTarget:self
action:@selector(requestDialogButtonClicked)
forControlEvents:UIControlEventTouchUpInside];
[self.viewController.view addSubview:requestDialogButton];
// ...
}
最佳答案
您是否在标头中声明了viewController
类型的UIViewController
并进行了合成?看来您正在用AppDelegate
做工作,我建议您不要这样做。您应该在viewcontrollers' viewDidLoad:
或viewWillAppear:
方法中实现这一点。
关于iphone - 在appdelegate.m文件中找不到viewcontroller,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7919687/