韌館-LearnHouse

Archive for the '程式&軟體' Category

在Mac OS X上用Homebrew安裝ffmpeg和ffplay

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝Homebrew:

brew info ffmpeg

查看ffmpeg安裝參數

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265

推薦安裝參數

brew update && brew upgrade ffmpeg

升級

brew install ffmpeg --with-ffplay

安裝ffplay
Read more...

posted by admin in 程式&軟體 and have No Comments

[iOS]UITextField常用設定

設置邊框樣式,只有設置了才會顯示邊框樣式
text.borderStyle = UITextBorderStyleRoundedRect;

typedef enum {
UITextBorderStyleNone,
UITextBorderStyleLine,
UITextBorderStyleBezel,
UITextBorderStyleRoundedRect
} UITextBorderStyle;

Read more...

posted by admin in 程式&軟體 and have No Comments

[iOS]Objective-C常用的Cocoa Touch API

dispatch_async

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // 耗时的操作
    dispatch_async(dispatch_get_main_queue(), ^{
        // 更新界面
    });
}); 

Read more...

posted by admin in 程式&軟體 and have No Comments

[轉]在使用 NSURLSession 時允許使用不安全的 SSL 連線

但很多時候你就會去做那些你不該做的事。比方說,你要寫一個 iOS 上的 Client,而 API Server 也還在開發中,接下來所有的 API 都會使用 HTTPS,但是還沒有花錢去買憑證,所以就先隨便產生了一個東西檔著先,而如果你使用 NSURLSession 試圖建立不安全的 HTTPS 連線的話,NSURLSession 就拒絕連線並且回傳 Error 物件。但是這種狀況下,你還是要先想辦法把連線建立起來,才有辦法在 Server 還在開發中的狀況下也寫點 Client Side 的程式。

Read more...

posted by admin in 程式&軟體 and have No Comments

[iOS]如何同時存在新舊兩套Xcode

身為iOS的開發人員很常會遇到iOS升級,Xcode也要跟著升級才能繼續開發

但很奇怪的是iOS每次升級,舊的APP就一定有問題,寫法都會有不相容新的SDK

勢必就要一一的去修正(真不懂為什麼Android就不用這麼麻煩)

有時候APP很趕著要上架,沒空一一修正和改寫不相容的錯誤

這時一個舊版的Xcode就很重要了,以下就教你如何安裝新舊兩套版本的Xcode

Read more...

posted by admin in 程式&軟體 and have No Comments

[轉]How to call Objective C code from Swift or Swift code from Objective C

Using Objective-C Classes in Swift

** If you have an existing class that you'd like to use, perform Step 2 and then skip to Step 5. (For some cases, I had to add an explicit #import <Foundation/Foundation.h to an older ObjC File) **

Step 1: Add Objective-C Implementation -- .m

Add a .m file to your class, and name it CustomObject.m

Step 2: Add Bridging Header

When adding your .m file, you'll likely be hit with a prompt that looks like this:

enter image description here

Click YES !

If you did not see the prompt, or accidentally deleted your bridging header, add a new .h file to your project and name it <#YourProjectName#>-Bridging-Header.h

Read more...

posted by admin in 程式&軟體 and have No Comments