2016年6月23日 星期四

Storyboard壞掉

今天同事把git上新的檔案拉下來

但發現storyboard壞了!!!

出現以下文字

An internal error occurred. Editing functionality may be limited

storyboard 的畫面無法編輯

可也不知是程式的問題還是 因為我們使用了最新的XCode 8 Beta的關係

但後來網路找了試了此方法



~/Library/Developer/Xcode/DerivedData 

該專案的暫存檔刪除

重新啟用xcode就正常囉!!

2016年4月17日 星期日

OSX El Capitan Apache問題

今天要使用OSX El Capitan版本 Apache時

 居然一直無法順利啟用apache 指令先下了

 sudo apachectl start cat /etc/hosts

裡面也有127.0.0.1 localhost

 但就是無法順利看見It works!

 後來執行apachectl configtest

 出現了下方的錯誤

 AH00526: Syntax error on line 20

of /private/etc/apache2/extra/httpd-mpm.conf:

 Invalid command 'LockFile',

 perhaps misspelled or defined by a module not included in the server configuration 

參考以下這篇 就能夠順利解決升上apache2.4的問題

 http://apple.stackexchange.com/questions/211015/el-capitan-apache-error-message-ah00526

 將/etc/apache2/extra copy一份 

sudo mv httpd-mpm.conf httpd-mpm.conf.elcapitan

sudo mv httpd-mpm.conf~orig httpd-mpm.conf

 sudo apachectl restart

apachectl configtest

取得"Syntax OK"

接下來一切就正常囉

2016年1月11日 星期一

[ios]判斷iPhone版本

 if( [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad ){
        self.label.text = @"iPad";
    }else{
        
        CGFloat detectionSize = 0;
        if ( [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait ){
            detectionSize = self.view.bounds.size.height;
        }else{
            detectionSize = self.view.bounds.size.width;
        }
        
        NSInteger ht = detectionSize;
        NSLog(@"ht:%ld",ht);
        switch (ht){
            case 480:
                self.label.text = @"iPhone 4S";
                break;
            case 568:
                self.label.text = @"iPhone 5/5s";
                break;
            case 667:
                self.label.text = @"iPhone 6";
                break;
            case 736:
                self.label.text = @"iPhone 6 Plus";
                break;
            default:
                self.label.text = @"iPhone";
        }

    }


Swift version


        if UIDevice.currentDevice().userInterfaceIdiom == .Pad{
            label.text = "iPad"
        }else{
            
            var detectionSize:CGFloat = 0
            
            if self.interfaceOrientation == .Portrait{
                detectionSize = self.view.bounds.height
            }else{
                detectionSize = self.view.bounds.width
            }
            
            switch detectionSize{
            case 480:
                label.text = "iPhone 4S"
            case 568:
                label.text = "iPhone 5/5S"
            case 667:
                label.text = "iPhone 6"
            case 736:
                label.text = "iPhone 6 Plus"
            default:
                label.text = "iPhone"
            }
        }