最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

参考教程开发iOS的第二个app:Storyboards – BirdWatching

iOS crifan 5081浏览 0评论

已经根据教程:Start Developing iOS Apps Today去折腾了很多了,相关帖子为:

【记录】使用Xcode中的iOS SDK给iphone开发出第一个App程序

管理你在Xcode中的工作流程

【整理】Object-C学习总结

Cocoa的Foundation Framework学习笔记

iOS Framework学习记录 + 理解iOS和OS X在Framework方面的区别和联系

在Mac的Framework下面写代码

学习记录Mac的App的设计模式

现在打算继续参考:Your Second iOS App: Storyboards,去折腾iOS的第二个app,storyboard,下面记录过程:


1.新建Master-Detail的iOS项目:

iOS  application Master-Detail

set new project

 

create folder

default created prj

编译一下,可以出现Master界面:

builded master

点击加号,可以创建一个子项:

added page

detail date time

可以看到Canvas中,详细的Storyboard/view信息:

cavas show

2.

创建相关的类:

new file

cocoa touch obj-c

birdsighting

create birdsighting

two created file

datacontroller

经过一番设置,变成:

table view

此刻,运行程序会出错,详见:

【已解决】Xcode中编译iOS程序,运行出错:Thread 1: signal SIGABRT

【已解决】UITableViewController setDataController:unrecognized selector sent to instance

解决了上面的错误,结果虽然可以显示主界面了,但是点击后,却进入不了详细界面了,不过后来终于解决了,详细折腾过程见:

【已解决】参考Your Second iOS App教程,但是点击BirdsMasterViewController中的TableView后,却无法进入详细页面BirdsDetailViewController

 

继续折腾。

参考:Your Second iOS App – Enabling the Addition of New Items,去添加AddSightingViewController:

AddSightingViewController

embed in navi ctrl

added add scene

 

new segue for add button

 

show add button

input birdname and location

added new tableViewCell

added new item info

 

终于按照教程搞定了这个app了。

 

再多说一句,上述折腾的期间,新建add scene时,不小心把从master view的add buttoncontrol+drag到add scene时产生的新的segue,不小心弄成了custom(而不是正确的modal),导致看到的segue图标都不对:

custom segue

所以运行时候,点击Add按钮,希望弹出add scene,结果出现了错误:

app abort

而且虽然已经在之前就添加了所有的breakpoint了,但是此时竟然没有跳转到对应的错误的地方。

不过此时才注意到,原来还有一个warning呢:

Unsupported Configuration: Custom segues must have a custom class

unsupported configuration

然后把segue改为对应的model,并添加上名字:

modal segue

这样,程序才可以正常运行,点击Add才可以转换到添加item的页面。

 

至此,终于完成教程中利用StoryBoard设计出来的BirdWatching的app了。

后续的根据:

Your Second iOS App – Next Steps

的建议,去做一些功能上的扩展的尝试,详见:

给Your Second iOS App的BirdWatching添加屏幕旋转(orientation rotation)的支持

 


【相关阅读】

有空再继续读这些相关的文章:

“Designing the Master Scene” and “Displaying Information in the Detail Scene”

“Enabling the Addition of New Items”

“Troubleshooting,” “Code Listings,” “Next Steps”

View Controller Programming Guide for iOS

Xcode 4 User Guide

Key-Value Coding Programming Guide

“Storing and Accessing Properties” in Cocoa Fundamentals Guide

转载请注明:在路上 » 参考教程开发iOS的第二个app:Storyboards – BirdWatching

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (11)

  1. 请教, 刚开始折腾iOS开发, 用的是最新版本的XCode, 然原著已经完全对不上新的系统。做创建项目的时候,无论怎选择,都是UISplitViewController模式,如何找回原书中的UINavigationController来学习?
    Sam8年前 (2016-05-27)回复
  2. 你这一系列的文章的源代码,那个地址貌似下载不了
    fanl198211年前 (2012-12-19)回复
    • 我刚去试了试,是可以的。 由于文件是放到skydrive上的。 而skydrive则偶尔有时候不稳定,所以导致偶尔无法下载,也是可能的。 换个时间去下载,就好了。
      crifan11年前 (2012-12-19)回复
  3. 急盼回复,我也是根据官网的文章来实现second ios app,遇到一个问题,在master 的处理addview 的done:segue方法里面,提示错误,../BirdWatching/BirdsMasterViewController.m:136:21: Property 'birdSighting' not found on object of type 'AddSightingViewController *'.该方法代码如下: - (IBAction)done:(UIStoryboardSegue *)segue{ if ([[segue identifier] isEqualToString:@"ReturnInput"]) { AddSightingViewController *addController = [segue sourceViewController]; if (addController.birdSighting) { [self.dataController addBirdSightingWithSighting:addController.birdSighting]; [[self tableView] reloadData]; } [self dismissViewControllerAnimated:YES completion:NULL]; } }
    fanl198211年前 (2012-12-19)回复
    • 希望能尽快回复我,谢谢
      fanl198211年前 (2012-12-19)回复
      • 估计你是你的当前的View的父类,没有设置好。 参考: Property 'View; not found on object of type “x” 中的, 选中对应的View,设置对应的Custom Class为合适的父类;
        crifan11年前 (2012-12-19)回复
        • 我看了一下,每个view对应的类设置应该都没有问题,能否给我你的qq或者邮箱,我将工程代码发给你,帮帮检查一下
          fanl198211年前 (2012-12-19)回复
          • 你之前发给我邮件,我已经回复了。你也就已经有了我的邮箱了。 所以,你再次回复我的邮件,不就可以贴附件,把你代码发过来了吗?为何还问我要邮箱?
            crifan11年前 (2012-12-19)回复
        • 另外,你这里的代码貌似无法下载了
          fanl198211年前 (2012-12-19)回复
          • “这里”指的是哪里?我当前这个帖子里,没有什么代码啊。 所以,请问可否一次性地,把问题说清楚了?
            crifan11年前 (2012-12-19)回复
        • 是编译时报错,不是ib的问题,编译不通过,
          fanl198211年前 (2012-12-19)回复
94 queries in 0.234 seconds, using 22.17MB memory