2016年5月4日 星期三

iOS tips - Force ImagePicker landscape view

ImagePicker如果沒加上一段神秘的code,在target只設定Landscape的話,一打開ImagePicker,系統不囉唆馬上給一個crash,要解決這問題很簡單,在會出現picker的view上加了這段code就沒問題了


- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeRight;

}

2016年4月29日 星期五

iOS tips - add delay

寫app時,不管是為了加上一些效果,或者是解一些奇怪的bug,常會需要加上delay然後來處理我們之後想要做的code,下面這段code就是delay 2秒然後處理另外的task

double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    //code to be executed on the main queue after delay
    [self doSometingWithObject:obj1 andAnotherObject:obj2];
});

2016年4月28日 星期四

iOS tips - PCH file in latest Xcode

記得好像Xcode 6之後PCH file在建project時就不會自動產生了,小弟不才,不知道把這拿掉的原因是啥,能夠有個標頭檔import常用到的file不是很好嗎?!下面這篇說明了要怎麼把pch file加回來.
http://stackoverflow.com/questions/24305211/pch-file-in-xcode-6

2016年3月29日 星期二

iOS tips error and warning handle collect

1. Unexpected CFBundleExecutable key
http://stackoverflow.com/questions/32096130/unexpected-cfbundleexecutable-key

2. Could not find Developer Disk image
http://stackoverflow.com/questions/33885080/xcode-7-1-with-ios-9-2-error-could-not-find-developer-disk-image

3. Debug unrecognized selector
http://blog.jackhl.com/2012/05/03/how-to-debug-objective-c-unrecognized-selector/

4. Avoid warning of “xxx in block is likely to lead a retain cycle"
http://stackoverflow.com/questions/7853915/how-do-i-avoid-capturing-self-in-blocks-when-implementing-an-api

5. Could not insert new outlet connection
http://stackoverflow.com/questions/15288773/could-not-insert-new-outlet-connection

6. SearchDisplayController‘ is deprecated: first deprecated in iOS 8.0


7. NSGregorianCalendar is deprecated: first deprecated in iOS 8.0

2016年2月24日 星期三

iOS tips - weak, strong, copy, , retain, assign概念介紹

寫了obj-c也兩年多了,但對於obj-c的properity一直沒有弄得很清楚,網路上找到了一篇文章之後,對於一些觀念有了比較清楚的認知,以下主要是參考這篇文章的心得
http://rypress.com/tutorials/objective-c/properties

2016年2月18日 星期四

iOS tips - gesture cancelsTouchesInView 屬性

最近因為一些功能需要加上gesture來做一些額外的動作,然後加上gesture的同時遇到了一些問題,找到了一個文章解決了我心中大部分的疑問!

http://blog.csdn.net/kylinbl/article/details/9139473

簡單來說,cancelsTouchesInView屬性的設定為NO時,在parentview加上的手勢就能不衝突的跟原本subview中的元件tap事件同時被觸發

2016年2月4日 星期四

iOS tips - xib subview overlay navigation bar

最近遇到一個挺怪的問題,用xib產生的view controller在被某個view controller以push方式呈現之後,xib中的一些物件會重疊到navigation bar,像是下面這樣