[IOS] 學習記錄(一)

原本是負責案子的後台API 制定開發,最近開始因為時間需要支援前端實現 ios app上類似 facebook like box 的頁面. 之前用 swift 寫過一個簡單的 gaming, 但對於 xcode 上寫真正的 app 還是頭一遭. anyway, 下面紀錄一下思路.

如何實現 facebook like box?
首先查了 developer.appple.com 這功能叫做 Table View  (create a table view)
目標:
    1.  storyboard, scene, view 的定義
    2.  table view, inspector (attribute, identity, etc.) 的操作
    3.  customise table view cell
    4. 如何使用 delegate 及 datasource
    5. swift 的 data types (array, string and OOP)
    6. display real data on table view

難度在於對於 view 跟 viewController 之間的 binding 的瞭解. xcode 簡化了很多,但是若沒讀一遍 manual 真的是窒礙難行.  (ex.  How to illustrate UITableViewControlller )

關於 Error "unexpected found nil while unwrapping an Optional value" 的二三事
 1. http://www.iphonelife.com/blog/31369/swift-101-working-swifts-new-optional-values
 2. http://www.appcoda.com/beginners-guide-optionals-swift/

如何 a-synchronizingly loading image
http://jamesonquave.com/blog/developing-ios-apps-using-swift-part-5-async-image-loading-and-caching/

如何改變 UITableView 的大小 跟 UIImage 的大小
其實就是 layout, 但是很關鍵的是要在 size inspector 裏頭 autoresizing 那裡做設定。不然程式碼裡面怎麼改 frame 他就是不會起作用 =..=
接著在  viewWillLayoutSubviews() 修改即可。(參考


如何在UITableView cell間增加空白 
這個作者的解法很漂亮,直接把 section 跟 rowInSection 調換, 然後 indexPath.row 改 indexPath.section 即可。(參考
1:    //uitableview (1)  
2:    func numberOfSectionsInTableView(tableView: UITableView) -> Int {  
3:      return mydata.count  
4:    }  
5:    //uitableview (2)  
6:    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {  
7:      return 1  
8:    }  
9:    //uitableview (3)  
10:    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {      
11:      var cell = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier,  
12:          forIndexPath: indexPath)!  
13:      var mid = mydata[indexPath.section]  
14:       ...  
15:    }  

TO-KNOW-NEXT
segue,  protocol and delegates (check source_1, )

最後,該死的 Apple 9/16 又更新了 xcode 到 7,  包括 swift 2 及 iOS9 API
Xcode 7 includes Swift 2 and SDKs for iOS 9, watchOS 2, and OS X 10.11 El Capitan.
至於會如何影響之前的程式碼,以及要如何修正,就在看吧... lol

Comments

Popular posts from this blog

股票評價(Stock Valuation) - 股利折現模型

openwrt feed的使用

How to convert Markdown into HTML