網頁

2014年3月25日 星期二

【iOS】針對某view進行固定方向的旋轉

【環境:xCode5.1 ios6 ios7】

xcode支持的旋轉設定如圖:


在旋轉的方向上,有多種不同的處理方法
1.
可以從application中,監聽哪些viewcontroller正在處理
若滿足某些條件
則進行device上的旋轉

2.對於從單一uviewController上,也可執行如圖,進行旋轉
可以在viewController中,看到此類地宣告。


As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月21日 星期五

【iOS】關於Prefix.pch file的那一點小事

【環境:ios】

關於Prefix.pch file這個檔案,剛剛翻了一下blog,發現竟然沒寫過
很早前就很想針對此file去特別寫一篇

prefix.pch file存在于每個objc procject環境中,android也會有
主要用來將常用的macro,至於此中


一般沒有太大意外的話,應該都是長這樣

可以看到文件中有特別針對某些項目去import


當你的project執行時,會先載入此檔案,去先行建立環境
如下圖:
可以看到我想要在每個頁面均可執行這些macro,然後利用他們的函示
我們也可將自己要檢查網路or判斷設定狀態的macro寫成一個lib然後由此嵌入,前提是我們想在大多數檔案中使用。

我們聽聽國外網友的意見:iOS Prefix.pch best practices

其他用法,可以在這邊寫入某些通用的巨集函數,如判斷裝置是否為568px or 480px
或者某些debug函數,如以下連結範例:

MY CURRENT PREFIX.PCH FILE




當然切記,沒有太大用途的,請勿胡亂一通的全塞進入,:)


As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月19日 星期三

【iOS】關於註冊開發者中心

【環境:iOS developer center】

關於註冊部分,
相信很多人,也常常搞混,希望我到現在還沒搞混,以下列為幾個重點

※註冊分為
1.Individual

2.company

之中最明顯的差別就是『D-U-N-S』的number
※『D-U-N-S』到底要不要付費(至於該如何取得,當你註冊時就會遇到)
->根據D-U-N-S的文檔可知,這是免費的。

※通常申請天數要等待幾天?
->平均申請時間為5-7天。

※而企業版的distribution:$299又是?
->這是針對in-house的用戶,通常申請上述一般$99的開發者帳號(無論個人/公司)
均有可對app store發佈app binary的功能。
至於$299,則是針對企業內部(名義上),若你想不需透過app store,release你的app,就請去申請此憑證。

※若你本來是『個人用戶』,想轉為『公司』的開發者(If I am enrolled as an individual, can I change to a company membership?)
->Yes. To convert your iOS Developer Program membership from an individual to a company, please contact us. You can make this change only if you are the founder/co-founder of the company. As part of the conversion process, you may be asked to submit business documents to verify your company's identity.



As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

【iOS】array 排序

【環境:ios7】

日期、字串排序,可在array中放入各種參數比較,相關參閱說明檔
NSSortDescriptor Class Reference
 
[array sortedArrayUsingSelector:@selector(compare:)] //升冪排序

 
//降冪
NSSortDescriptor *SortDescriptor=[NSSortDescriptor sortDescriptorWithKey:Nil ascending:NO selector:@selector(compare:)];
[Array sortedArrayUsingDescriptors:[NSArray arrayWithObject:SortDescriptor]];

 
//自定
NSSortDescriptor *sortDescriptor=[[NSSortDescriptor alloc]initWithKey:@"排序名稱" ascending:isAscending];
NSArray *sortDescriptors=[NSArray arrayWithObject:sortDescriptor];
NSArray *Array=[arr sortedArrayUsingDescriptors:sortDescriptors]; 

 
//block
NSArray *sortedArray;
sortedArray = [drinkDetails sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
    NSDate *first = [(Person*)a birthDate];
    NSDate *second = [(Person*)b birthDate];
    return [first compare:second];
}];


As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月15日 星期六

【synology】vpn

【環境:synology DSM 5.0,MAC】

synology vpn介紹

vpn(Virtual Private Network),虛擬私人網路,如上圖,用戶連線到網際網路,透過vpn連線到某個的私人網路。
而該私人網路下的設備or應用程式,可以設定不直接對外開放。(亦即只要有開放port對外設定,亦可直接對外)
故利用vpn連線到私人網路,可提供安全、加密的網路環境,供企業內部的員工在非該區域網路中依然可以透過安全連線取得某些資料。


若你的synology已經透過路由器,開通了某些服務(port)直接對外,請關閉,才可發揮vpn功能。
ex:
ssh:22 port,不直接對外,故可透過先連到vpn,再連線到。
而你的防火牆,可設定連線到ssh的某些ip/mask全部ban掉。

設定上參考上面的synology vpn教學。

這邊稍微講一下,該如何連線。
1.先確定你的router,synology可直接連線到net,並設定好vpn。
px:假設你對外 ip:51.64.192.83 , vpn設定的ip:10.0.0.0

2.此時確定你的其他服務,尚未可連線到網路,如果你是用router設定,請去檢查,如果你是利用synology的『路由器配置』,請去關掉你不想直接對外的服務port。
ps:某些功能需點開『啟用設定』,像ftp...

3.開啟你的vpn連線,ip:51.64.192.83

4.開啟你的ftp,連線位置10.0.0.0,port:21,輸入DSM帳密即可。

可檢查若無連線到vpn,是否可連線到ftp,若可以,代表你的ftp的服務有直接連線到網路上。



As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月14日 星期五

【ios】status bar hidden

【環境:ios6,7】


ios6只需要以下
 
[[UIApplication sharedApplication] setStatusBarHidden:YES]; 

ios7
 
[[UIApplication sharedApplication] setStatusBarHidden:YES]; 
且在plist中設定View controller-based status bar appearance,如圖:





As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月12日 星期三

【iOS】Cannot install applications because the certificate is not valid

【環境:OTA】

最近重新架設OTA,發生了如圖,的慘狀
一開始我還以為我哪個xcode中的憑證弄錯,重新搞了好久,畢竟以前也沒碰過這個問題
稍微survey一下,原來ios7以上的版本,必須透過安裝server ssl憑證,才可以下載。

所以我回到ios6以下的幾種,果然可以正常安裝
且利用https,在ios6以下並沒辦法安裝

基本上,只需將以下改掉即可
itms-services://?action=download-manifest&url=https://yourdomain.com/manifest.plist
plist中無需更改,聽說是因為apple更改了manifest.plist的權限,只能用https授權過的ssl才可下載安裝,故若你的domain name要可使用OTA的服務,就請去申請安裝ssl憑證吧....
這點我也在try.....

所以....自己在server建立的自我憑證...這是不夠的
https://twitter.com/renderplace/status/426754821044338689
會發生如下圖:



而聽說透過dropbox的免費網頁服務,可以作為暫時之計。

使用方法:(其實只需將plist放至dropbox即可,只是我想都放在一起)
1.將你的plist放至dropbox。
2.對ipa按右鍵,取得分享連結,像此:www.dropbox.com/y/20i6qogfvim7tcy/xxx.ipa
3.將www.dropbox.com改為dl.dropboxusercontent.com
3.開啟你的plist,更改下載的位置如上,也可順便用https傳輸。
4.上傳plist,並取得你plist的分享link,像:www.dropbox.com/c/20i6qogfvim7tcy/xxx.plist
5.將www.dropbox.com改為dl.dropboxusercontent.com
6.回itms-services://?action=download-manifest&url=https://dl.dropboxusercontent.com/a/20i6qogfvim7tcy/xxx.plist


聽說許多國外的開發者,針對這點,有所不滿,畢竟apple每次動這些東西似乎都不會特別提醒...畢竟我也意外被打鎗許多次....

而我也試圖去developer center尋找相關文擋,似乎OTA的部分dis,已經被移除。

下次來寫安裝ssl的流程。



As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月11日 星期二

【vsftp】設定某些特定用戶,只能存取自己的目錄

【環境:aws】

當我們開啟一個ftp的帳號權限useradd,passwd
總是會考慮安全性的問題

此時請到
 
/etc/vsftpd

設定vsftpd.conf
 
vim vsftpd.conf

可看到以下的資訊
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_local_user=NO
chroot_list_enable=YES
# (default follows)

chroot_list_file=/etc/vsftpd/chroot_list

如上,我設定chroot_local_user = NO
例外的帳號,設定在chroot_list上

chroot_list的不受限帳號


每次設定完成,請重新開啟VSFTP
 
sudo service vsftpd restart

同樣的,若你想限制某些用戶只能在特定目錄下進行操作,請參考

VSFTP安裝

裡面有更改root()的設定

As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

【AWS】FTP ,NO SFTP

【環境:aws】

每次年代久遠,換個電腦,總是會忘記之前設定
例如aws的ftp

【AWS】VSFTP安裝 請看此


用ec2-user登入,無需密碼,但你必須用.pem登入sftp
加上你的user不可能每個人發一個,追蹤log也很重要

1.首先必須去aws上,建立一個帳號與密碼,詳情請參閱鳥哥大神

2.在filezilla上,設定主動模式。(若你的dreamwaver要用svn亦用此主動模式)

輸入你的帳秘即可....




As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

【AWS】Permissions 0644 for 'xxx.pem' are too open.

【環境:aws】

常常在把key丟來丟去的時候,常常會發生權限過於開放的問題

此時只需把權限改為600即可

chmod 600 xxx.pem

順道一提

在aws的security將ssh的inbound設定成某個網域才可進入,較為保險
source的0.0.0.0/0
mask設定成你私人的網域較好


As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月10日 星期一

【AWS】FREE TIERS

【環境:AWS】

今天早上收到aws的信件『Your AWS Free Tier Period is Expiring
害我稍微緊張了一下
因為根據我以前survey的文件資料,應該不論新舊用戶,均無12月的受限

於是我就又去找了一下相關資訊
** These free tiers do not expire after 12 months and are available to both existing and new AWS customers indefinitely.

link:http://aws.amazon.com/free/

所以或許應該建議一下aws的客服端,把此封mail拿掉,不然真的會嚇一跳

不過我記得超過12個月,他在賬單上的計算方式為,會有部分的費率,但會扣除可折抵的費用,所以基本上也是0元(ex:Micro ec2,你用了500個小時,但你有可扣底的750小時)。

而之前的免費方案方式為,賬單上都是0元。

As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。

2014年3月4日 星期二

【iOS】XCode cannot run using the selected device. Choose a destination with a supported architecture in order to run on this device.

【環境:xCode 5.0.2】

把舊的code拿出來compiler,出現以下錯誤


原因為objective c 需用LLVM5.0
位置在project - > build settings - > build options - > Compiler........
如下圖


As always , if you have any question , feel free to contact me.
有任何問題,請聯絡我

歡迎轉載,請註明出處,感謝。