2013年5月7日 星期二

Storyboard 相關資訊及注意事項

Storyboard需iOS 5、XCode 4.2以上版本才開始支援。
  1. 其基礎為xib,增加其功能,與xib最明顯不同處在一個xib檔,僅代表一個screen,而一個strotyboard可包含多個screen。
  2. 一個專案中不限制只能有一個Storyboard檔案,可多個檔案並存,但若此取此方式,這可能就失去Storyboard其原有的意義了。
    但是,若同時支援iPhone與iPad,Storyboard需分別使用不同的Storyboard檔案,並在info.plist中進行相關設定。
  3. 採用Storyboard的專案除可使用Storyboard進行開發之外,也可同時使用xib進行開發
  4. 在view controller切換,除了以原先以model或是navigate controller push的方式之外,另外增加了以segue方式切換。
注意事項:
  1. 採取Storyboard多人協同開發,並進行版本控制時,與xib有想同的問題,若同時對同一檔案維護時,可能會發生衝突問題。
  2. 另外,在iOS 6與iPhone 5釋出時,為配合iPhone 5 4吋螢幕,Storyboard增加了Autolayout功能,但該功能限制要最低版本為iOS 6以上,若在iOS 5編譯時程式會直接crash。

2013年3月11日 星期一

- drawRect: CGRectInset

最近用到了一個指令
CGRectInset(CGRect rect, CGFloat dx, CGFloat dy)
老是搞不清楚運作的方式
所以做了個實驗並將果記錄下來

rect = (0, 0 ,320, 480)
     
     CGRectInset(rect, 0, 0)    =>    x = 0.000000,   y = 0.000000,   width = 320.000000, height = 480.000000
     CGRectInset(rect, 10, 0)   =>    x = 10.000000,  y = 10.000000,  width = 300.000000, height = 480.000000
     CGRectInset(rect, 20, 0)   =>    x = 20.000000,  y = 20.000000,  width = 280.000000, height = 480.000000
     CGRectInset(rect, 0, 10)   =>    x = 0.000000,   y = 0.000000,   width = 320.000000, height = 460.000000
     CGRectInset(rect, 0, 20)   =>    x = 0.000000,   y = 0.000000,   width = 320.000000, height = 440.000000
     CGRectInset(rect, 10, 20)  =>    x = 10.000000,  y = 10.000000,  width = 300.000000, height = 440.000000
    
     CGRect newRect = CGRectInset(CGRect rect, CGFloat dx, CGFloat dy)
     
     newRect.origin.x = dx;
     newRect.origin.y = dx;
     newRect.size.width = rect.size.wide - dy * 2
     newRect.size.height = rect.size.height - dy * 2

2013年2月26日 星期二

錯誤訊息_2013-02-26

*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__nsarraym: data-blogger-escaped-0x75828d0=""> was mutated while being enumerated.'
*** First throw call stack:
(0x15a1012 0x12aee7e 0x1629cc5 0x3ec3 0x12c2705 0x1f62c0 0x1f6258 0x2b7021 0x2b757f 0x2b66e8 0x225cef 0x225f02 0x203d4a 0x1f5698 0x2603df9 0x2603ad0 0x1516bf5 0x1516962 0x1547bb6 0x1546f44 0x1546e1b 0x26027e3 0x2602668 0x1f2ffc 0x2bdd 0x2b05)
libc++abi.dylib: terminate called throwing an exception

今天遇到了一個問題
Google "NSGenericException"之後找到了問題
起因是因為我要刪除Array中某元素所造成

這問題主因簡單來說就是太多層了
系統來不及反映所導致

比如說:我要刪除 a.array[0].array[1]
這樣就有可能會發生問題

2013年2月23日 星期六

Responds To Selector

在@select時
如果沒有選好常會有當掉的狀況
搜尋了一下
有篇文章的方法不錯記錄下來
http://blog.csdn.net/dongdongdongjl/article/details/8498555

使用respondsToSelector@select(Method)
來判斷是否有此Method
這樣就比較不會當掉了

iOS5 Deprecated Method

在iOS6推出之後有些Method被廢棄了
在這紀錄iOS5 Deprecated Method
然後應該換用的Method

//Deprecated
self presentModalViewController:(UIViewController *) animated:(BOOL)
//改用
self presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion

2013年2月22日 星期五

弧度角度轉換

老是忘記角度轉換
紀錄一下

角度轉換弧度
Degrees * PI /180 = Radians

弧度轉換角度
Radians * 180 /PI = Degrees

參考:wiki 弧度

Core Graphics Note

零散地記錄一下Core Graphics相關的筆記

方便日後搜尋

//繪製弧形使用
CGContextAddArc
(
CGContextRef c, //繪製本文
CGFloat x,
CGFloat y, //圓心(x, y)
CGFloat radius, //半徑
CGFloat startAngle, //開始角度,輸入為弧度角
CGFloat endAngle, //結束角度,輸入為弧度角
int clockwise //順時鐘為1、逆時鐘為0,
)