2016年5月17日 星期二

iOS tips - Remove subviews at once

當我們create了一個UIView後,常常有可能在上面加了許多的subview,而之後需要清除這些subview再做其他的處理,只需要一行code就可以做到清除所有subview的動作

2016年5月11日 星期三

iOS tips - Crop Image

因工作需求,需要將影片的thumbnail剪半再rotate,stackoverflow後總算完成,做個小筆記
重點就是使用CGImageCreateWithImageInRect使用將原本的Image重設rect為想要的size

2016年5月9日 星期一

iOS tips - PopoverView on iPhone

在iPad上的menu選單常常可以看到popover方式呈現的menu,但不知為何在iPhone上不能implement,不過iOS 8之後iPhone也可以透過別的方式實現了

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