zouzhiheng 2014-12-28 02:20 采纳率: 33.3%
浏览 1822
已采纳

IOS view跳转返回时出现错误

AppDelegate:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;

第一个viewcontroller:
SecondViewController *second=[[SecondViewController alloc] init];
second.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentViewController:second animated:YES completion:^{}];

第二个:
[self dismissViewControllerAnimated:YES completion:^{}];

出现的错误:
Thread 1:Program received signal : "SIGABRT"

xib文件我都有连线

小白,刚开始学IOS,发现书上的版本太旧,现在看别人博客来学习,竟然还出现错误,无奈。。。

  • 写回答

4条回答 默认 最新

  • 泉哥爱phone干货 2014-12-31 07:00
    关注

    看到上面的问题和众位的回答,我算是抛砖引玉吧,对于你这样的初级学习者可以从官方的例子入手,例子下载地址:xcode--help--documentation and API Reference--在搜索框输入uicatalog 然后就可以看到例子了,然后点击open project 然后xcode会自动下载程序,下载后会自动打开,另外这个例子包含基本的控件的使用,有oc何swift两个版本,希望对你有用图片说明

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • WorldMobile 2014-12-28 08:07
    关注

    正常,建议从网络上下载电子版的书籍,学习后再研究例子,至于你的问题,可以找一个博客的主人问一下

    评论
  • ReyZhang 移动开发领域新星创作者 2014-12-29 00:38
    关注

    尝试把你的ViewController embed in UINavigationController ,将这个作为window的根控制器。根控制器最好是一个容器控制器,像UINavigationController, UITabbarController .

     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    UINavigationController *navController  = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = navController;
    
    

    其它的代码不变,按你原来的方式。再重试。

    评论
  • __block小凡 2014-12-30 09:53
    关注

    仅仅几段demo,问题很多,为何需要在APPDelegate中将ViewController设置为属性,设置也就设置了,使用ViewController这种命名,也太草率了,或者你用的是xcode6自动生成的?而且新手一上来就是用xib,很容易在生命周期上出问题,demo多写有益,问题不难,想要学会,自己解决,iOS中,一切关于UI的问题都不是问题

    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题,请各位专家解答!(相关搜索:java程序)
  • ¥15 linux tsi721的驱动编译后 insmod 提示 报错
  • ¥20 multisim测数据
  • ¥15 求无向连通网的所有不同构的最小生成树
  • ¥15 模拟器的framebuffer问题
  • ¥15 opencv检测轮廓问题
  • ¥15 单点式登录SSO怎么爬虫获取动态SSO_AUTH_ACCESS_Token
  • ¥30 哈夫曼编码译码器打印树形项目
  • ¥20 求完整顺利登陆QQ邮箱的python代码
  • ¥15 怎么下载MySQL,怎么卸干净原来的MySQL