这里有人可以帮助我吗?我构建了一个 iOS 插件,当我尝试呈现 ViewController 时出现错误。 “[FacebookPlugin showFBPost]:发送到实例 0x21240b00 的选择器无法识别 (lldb)“
这是我尝试调用的代码。预先感谢您的帮助。
#import "FPlugin.h"
#import "FSendViewController.h"
#import "UnityAppController.h"
#pragma mark - Unity methods
@implementation FPlugin
extern UIViewController *UnityGetGLViewController();
void showFBPost(){
UIStoryboard *mainStoryBoad = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UIViewController *vc = [mainStoryBoad instantiateViewControllerWithIdentifier:@"MainViewController"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
UIViewController *rootViewController = UnityGetGLViewController();
//[rootViewController presentViewController:vc animated:YES completion:^(){}];
[rootViewController presentModalViewController:vc animated:YES];
}
extern "C" void ShowFBPost()
{
FPlugin * obj = [FPlugin alloc];
[obj showFBPost];
[obj release];
}
@end
以前使用 xib 它可以很好地工作
UIViewController *rootViewController = UnityGetGLViewController();
SendFacebookViewController *sfvc = [[SFViewController alloc] initWithNibName:@"SendFacebookViewController" bundle:nil];
[rootViewController presentModalViewController:sfvc animated:YES];
[sfvc release];
最佳答案
我把它改成这个就发现了问题
extern "C" void ShowFBPost()
{
//FPlugin * obj = [FPlugin alloc];
//[obj showFBPost];
//[obj release];
showFBPost();
}
/* Note: File extension .mm */
关于ios - 在 iOS 中调用 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19507061/