iOS sdl使用

iOS上sdl使用方法:

1)、官网上下载文件后再docs->readme.ios文档里记载的

4、Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iOS provides its own UIApplicationDelegate.  Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically.

5.  Delete the contents of main.m and program your app as a regular SDL program instead.  You may replace main.m with your own main.c, but you must tell Xcode not to use the project prefix file, as it includes Objective-C code.

首先需要删除app delegate.h .m文件,因为sol提供自己的UIApplicationDelegate,同时删除MainWindow,并在info.plist删除(其实不删除也行,只要从main函数入口进入时,入口处删除默认进入程序的代码,也就不会进入默认的appdelegate)

然后删除main.m文件里的内容,将int main(int argc, char * argv[]替换成extern C_LINKAGE int SDL_main(int argc, char * argv[])。

extern C_LINKAGE int SDL_main(int argc, char * argv[])
{
    @autoreleasepool {
        ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
        [UIApplication sharedApplication].keyWindow.rootViewController = viewController;
        [[UIApplication sharedApplication].keyWindow makeKeyAndVisible];

        return 0;
    }
}
遇到的问题:

1)不按上面的方法做,直接通过默认方式进入控制器,使用sdl_init初始化,就会初始化不成功,原因是没有在入口main函数中调用sdl_main函数。但如果不改变main.m文件中int main(int argc, char * argv[]为extern C_LINKAGE int SDL_main(int argc, char * argv[]),就需要在main.m文件里先进行sdl_init初始化

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值