跳到主要內容

文章

目前顯示的是 2015的文章

[IOS] xcode 複製專案並修改專案名稱

xcode 複製專案並修改專案名稱 1.將專案copy到新的folder下(OLD->NEW) 2.用xcode打開OLD.xcodeproj 3.將專案名稱點兩下直接改名,改完後clean and close 4.回到NEW目錄下將所有的資料夾及檔案名稱全改成NEW 5.對NEW.xcodeproj顯示套件內容,用xcode打開project.pbxproj,將所有的OLD換成NEW 6.到manager schemes修改scheme名稱 搞定 !

[IOS] Remote logging

使用 https://logentries.com 註冊完後就直接來新增一個log set                   這裡我是用IOS                     這裡我是設定App名稱               下載lib到Project裡,把 lelib 資料夾拉進xcode裡           很貼心,把相關程式都寫出來                                         完成!超簡單!      

[IOS] 一些切割圖片的套件

可以在圖片上拉一個隨意的方形來切割 (Objective-C) https://github.com/myang-git/iOS-Image-Crop-View   先設定一個圖形的mask,讓圖片可以在後面拖拉縮放(Objective-C) https://github.com/DuncanMC/CropImg   https://github.com/gavinbunney/Toucan

[Swift] 將 TableView 或 CollectionView 的 Cell 加上類似 button 的 TouchDown 的效果

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { override func viewDidLoad() { super.viewDidLoad() self.tableView.dataSource = self self.tableView.delegate = self // 加上這一行才不會看不到TouchDown的效果 self.tableView.delaysContentTouches = false //... } //... // MARK: - UITableViewDelegate func tableView(tableView: UITableView, didHighlightRowAtIndexPath indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath)! cell.alpha = 0.3 } func tableView(tableView: UITableView, didUnhighlightRowAtIndexPath indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath)! cell.alpha = 1 } }

[Swift] 幫 UITextField 增加一個 done 按鈕

func addDoneButtonOnKeyboard(targetField:UITextField) { let doneToolbar: UIToolbar = UIToolbar(frame: CGRectMake(0, 0, 320, 50)) doneToolbar.barStyle = UIBarStyle.BlackTranslucent let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil) let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Done, target: self, action: Selector("doneButtonAction")) var items = Array<UIBarButtonItem>() items.append(flexSpace) items.append(done) doneToolbar.items = items doneToolbar.sizeToFit() targetField.inputAccessoryView = doneToolbar }

coffee

                                       

[iOS] Log file for iOS

目的︰用檔案記錄log,以時間組成檔名(yyyyMMddHHmmss),只保留7天 做法︰ 1. 使用XCGLogger來記錄log 2. 每次APP啟動時,檢查log檔案是否有超過7天的,超過就刪除 // AppDelegate.swift import XCGLogger struct MyVariables { static let logger = XCGLogger.defaultInstance() static let documentsPath = NSHomeDirectory() + "/Documents" } class AppDelegate: UIResponder, UIApplicationDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // 清除7天前的log檔 cleanOldLogFile() // 產生此次log的檔名 let postFixFormatter = NSDateFormatter() postFixFormatter.dateFormat = "yyyyMMddHHmmss" postFixFormatter.locale = NSLocale.currentLocale() let logFileName = "Ticket_" + postFixFormatter.stringFromDate(NSDate()) + ".log" let logFileWithFullPath = MyVariables.documentsPath.stringByAppendingString("/\(logFileName)") let dateFormatter = NSDateFormatter

[iOS] Google Ad 新增 插頁式 廣告

Google 官方 的 教學 怪怪的 不work https://developers.google.com/admob/ios/interstitial?hl=zh-tw   以下目的為加入插頁式廣告,廣告在該頁面載入時會顯示,關閉後會啟動計時器,在30秒後再自動開啟   // CSPViewController.h @import GoogleMobileAds; @interface CSPViewController : UIViewController @end // CSPViewController.m @interface CSPViewController () @property(nonatomic, strong) GADInterstitial *interstitial; @end @implementation CSPViewController{ NSTimer *timer; } - (void)viewDidLoad{ // ... // 加入插入式廣告 self.interstitial = [self createAndLoadInterstitial]; } - (GADInterstitial *)createAndLoadInterstitial { GADInterstitial *interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-6497987983526708/719163474"]; interstitial.delegate = self; [interstitial loadRequest:[GADRequest request]]; return interstitial; } - (void)interstitialDidReceiveAd:(GADInterstitial *)ad { [self.interstitial presentFromRootViewController:self]; } - (void)interstitialDidDismissScreen:(GADInter

[iOS] 打分數 的 功能

今天 User 要求要做 “幫我們打個分數吧” 的功能 這應該只是在 click 後 打開 appStore 來 打分數 查了一下 open url 的方式 https://developer.apple.com/library/ios/qa/qa1629/_index.html // Objective-C NSString *iTunesLink = @“itms://itunes.apple.com/us/app/apple-store/id375380948?mt=8"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; // Swift UIApplication.sharedApplication().openURL(NSURL(string: "itms://itunes.apple.com/us/app/tai-gu-ying-shou-fen-xi/id986799180?mt=8")!)   Url Format itms-apps://itunes.apple.com/app/idAPP_ID ex: itms-apps://itunes.apple.com/app/id986799180     取得iTunes url 的方式 1.Launch iTunes on your computer. 2.Search for the item you want to link to. 3.Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu. 4.In your application, create an NSURL object with the copied iTunes URL, then pass this object to UIApplication' s openURL: method to open your item in the App Store.

[iOS] Auto Layout 筆記

  Autolayout 中的 百分比 宽度 http://maogm.com/blog/percentage-width-in-autolayout.html 這招太實用啦 1.先設定該元件與父元件Equal Width的Constraint 2.再將該Constraint的Multiplier設定需要的比例(ex: 0.5,表示50%)   为iPhone6设计自适应布局(一) http://www.devtalking.com/articles/adaptive-layout-for-iphone6-1/   SnapKit http://snapkit.io/docs/ 居中 let view1 = UIView() view.addSubview(view1) view1.snp_makeConstraints{(make)->Void in make.edges.equalTo(view).insets(UIEdgeInsetsMake(20, 20, 20, 20)) } 等宽 let view2 = UIView() let view3 = UIView() view1.addSubview(view2) view1.addSubview(view3) view1.addSubview(view4) view2.snp_makeConstraints{(make)->Void in make.top.equalTo(view1.snp_top).offset(20) make.width.equalTo(view3) make.left.equalTo(view1.snp_left).offset(20) make.right.equalTo(view3.snp_left).offset(-20) make.height.equalTo(200) } view3.snp_makeConstraints{(make)->Void in make.top.equalTo(view1.snp_top).offset(20) make.width.equalTo(view2) make.right.equalTo(view1.snp_

[TroubleShooting] ITMS-90096

                      今天在打包APP上傳時,發生了這錯誤 網路上查了一下,都說這是Launch Screen的問題 說要放置Default-568h@2x.png這個檔案 但我的LaunchScreen的圖並不是全螢幕的,只是一張置中的小圖 最後發現是我在LaunchScreen.xib裡面,直接拉了一張圖進去 而不是使用image view! 修正為使用image view,再將圖設定進image view後就可上傳成功了!

[iOS] iPhone 尺寸圖

[iOS] Share Screenshot to Facebook

如何將手機螢幕截圖分享到臉書︰   設定Navigation Bar按鈕 - (void)viewDidLoad { UIBarButtonItem *shareBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(saveScreenshotToPhotosAlbum:)]; //[self.navigationItem setRightBarButtonItem:shareBtn]; [self.navigationItem setRightBarButtonItems:[self.navigationItem.rightBarButtonItems arrayByAddingObject:shareBtn]]; }   按鈕事件 - (void)saveScreenshotToPhotosAlbum:(UIView *)view { if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){ self.mySLComposerSheet = [[SLComposeViewController alloc] init]; self.mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; [self.mySLComposerSheet setInitialText:@"Some Text"]; [self.mySLComposerSheet addImage:[self captureView:self.view]]; [self presentViewController:self.mySLComposerSheet animated:YES completion:nil

[iOS] 好用的3rd-party libraries

  Label跑馬燈: https://github.com/cbpowell/MarqueeLabel   HTML/XML Parser相關: 以前用apple,今天看到一個叫Ji的,試用先! https://github.com/honghaoz/Ji   Logger相關: https://github.com/DaveWoodCom/XCGLogger   AutoLayout相關 SnapKit: https://github.com/SnapKit/SnapKit https://github.com/SnapKit/SnapKit

[TestNG] - testng.xml

Testing.xml 的主要結構 根標籤是<suite> <suite> 標籤包含一個或多個<test> 標籤 <test> 標籤包含一個或多個<classes> 標籤 <classes> 標籤包含一個或多個<method> 標籤 一般來說,大多數文件詳細到<classes> 標籤即可。 Testing.xml 的額外標籤 <packages> 和<package> :顧名思義,它們可以指定一組java 包,在這個標籤中還可以用包含<include> 或者排除<exclude> 屬性。 <parameter> 定義了參數名稱和值,它的使用是與測試類當中@Parameters 的註釋結合使用的,作用和@Dataprovider 類似,提供外部參數,功能不如@Dataprovider 強大,有局限性。 <suite-files> 和<suite-file> :它是用來引入其他testng.xml 文件的,這些文件將於當前文件一起執行。 <groups> ,<define> 和<run> :這三個標籤結合使用,在執行時用來指定或者排除一部分的分組   注意執行測試的默認順序是按照testng.xml 裡給定的順序執行的。如果你不希望按此順序執行,請使用preserve-order 屬性指定為false。如<test name="Regression1" preserve-order="false"> 。   參考︰ 單元測試框架TestNg使用總結  http://nighthawk.iteye.com/blog/1502482

[Swift] 取得目前使用的語系

  // 取得目前語系環境 let userDefaults: NSUserDefaults = NSUserDefaults.standardUserDefaults() let aray: NSArray = userDefaults.objectForKey("AppleLanguages") as! NSArray let currentLanguage = aray.objectAtIndex(0) print("Current language: \(currentLanguage)") let locale = NSLocale.currentLocale() let trans = locale.displayNameForKey(NSLocaleIdentifier, value: currentLanguage) print("Localized display name: \(trans!)") Console output: Current language: en-TW Localized display name: English (Taiwan)

[Swift] UIView Shadow

為UIView加上陰影 backView.layer.shadowOffset = CGSize(width: 3, height: 3) backView.layer.shadowOpacity = 0.7 backView.layer.shadowRadius = 2 backView.layer.shadowColor = UIColor(hexString: "#3A4355")!.CGColor 參考︰ Shadow effect in swift on UIView http://gracefullycoded.com/shadow-effect-in-swift-on-uiview-uilabels/ Playing with UIView shadows in Swift http://mookid.dk/oncode/archives/3780

[Java] gradle

  mac下配置gradle的环境变量 http://blog.csdn.net/tammy_min/article/details/21597083   實際路徑 /Users/kirk/Documents/java/gradle/gradle-2.7/bin   Gradle命令行黑魔法 http://www.cnblogs.com/huang0925/p/3295862.html   Android Studio系列教程五--Gradle命令详解与导入第三方包 http://stormzhang.com/devtools/2015/01/05/android-studio-tutorial5/     Chapter 64. The Gradle Wrapper https://docs.gradle.org/current/userguide/gradle_wrapper.html   【認識 Gradle】(3)Gradle 起手式 http://www.codedata.com.tw/java/understanding-gradle-3-getting-started/ 【認識 Gradle】(5)Gradle Task 觀念導讀 http://www.codedata.com.tw/java/understanding-gradle-3-gradle-task-abc/   How can I tell Gradle to use my testng.xml file for Test Classes and Ordering? http://stackoverflow.com/questions/4762945/how-can-i-tell-gradle-to-use-my-testng-xml-file-for-test-classes-and-ordering test { useTestNG() { // runlist to executed. path is relative to current folder suites 'src/test/resources/runlist/my_test.xml' } }   錯誤: 找不到或無法載入主要類別 org.gr

Swift 2.0 - WTF

How to call SecItemCopyMatching in Xcode 7 beta 4? http://stackoverflow.com/questions/31549059/how-to-call-secitemcopymatching-in-xcode-7-beta-4   编译ImageIO库type 'CFString!' does not conform to protocol 'NSCopying' http://blog.csdn.net/wenzfcsdn/article/details/43759849   NSCopying协议和copy方法 http://www.cnblogs.com/gogoagg/archive/2011/12/20/2294818.html http://www.cokco.cn/thread-53738-1-1.html http://blog.csdn.net/hello_hwc/article/details/47682143   How to call SecItemCopyMatching in Xcode 7 beta 4? http://stackoverflow.com/questions/31549059/how-to-call-secitemcopymatching-in-xcode-7-beta-4 let statusCode: OSStatus = SecItemCopyMatching(keychainItemQuery, &secureItemValue) let status: OSStatus = withUnsafeMutablePointer(&dataTypeRef) { SecItemCopyMatching(keychainQuery as CFDictionaryRef, UnsafeMutablePointer($0)) }   Swift1.2 -> Swift2 http://fiahfy.blogspot.tw/2015/09/swift12-swift2.html   Strings in Swift 2 https://developer.apple.com

Appium for iOS

  如何使用Command來build *.app Building and deploying iOS app for Appium tests (CI) https://discuss.appium.io/t/building-and-deploying-ios-app-for-appium-tests-ci/3732   Appium腳本 - for Node.js Start Automating Native iOS testing with Appium using Node.js https://www.built.io/blog/2015/03/start-automating-native-ios-testing-with-appium-using-node-js/ sample-code https://github.com/appium/sample-code   移除Appium npm uninstall appium -g   移除node.js https://gist.github.com/ddo/668630454ea0d74fdc21 curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh chmod +x ./uninstall-node.sh ./uninstall-node.sh rm uninstall-node.sh   重新安裝node.js (這樣安裝才不需要root) brew install node   has some problum : brew link node sudo chown -R `whoami` /usr/local/

格式化Blogger文章

FORMAT MY SOURCE CODE FOR BLOGGING http://formatmysourcecode.blogspot.tw/ 測試內容   幫 Blogger 文章鎖上密碼 方案1(重編輯後會不能用…) http://apps.kerthis.com/encrypt-post/ 方案2(推) http://freeingcockatiel.blogspot.tw/2014/02/google-blog.html http://xox520.blogspot.com/2011/04/hide-post-in-blogger.html 加密位置 http://www.vincentcheung.ca/jsencryption/ http://xox520.blogspot.com/p/encoder.html?m=1 Demo 測試用密碼:test 顯示加密內容   SyntaxHighlighter http://pydoing.blogspot.tw/2010/11/syntaxhighlighter-blogger.html http://blog.xuite.net/andy19890411/Orz/37326267 http://alexgorbatchev.com/SyntaxHighlighter/download/ https://github.com/syntaxhighlighter Demo func getCurrentDateTimeString()->String{ let date = NSDate() let calendar = NSCalendar.currentCalendar() let components = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second, .Weekday, .WeekdayOrdinal] , fromDate: date) let year = components.year let month = String(format: "%02d", components.month)

Sublime

Sublime 安裝 Package Control 1. 按下 command + ~ 2. 貼上 import command https://packagecontrol.io/installation#st2   JsFormat ( 排版 ) cmd + alt + f   JSHint ctrl + j   Pretty JSON ctrl + alt + j   Alignment ctrl + alt + a   Trimmer ctrl + alt + s   Find Function Definition F8   keymapManager ctrl + alt + k   Appium https://github.com/webdriverio/sublime-bundle

好用的尋找Path工具 - Firepath

特地要寫下來是因為我這次又需要找XPath時,完全把它給忘了…真的是老了啦     Firepath https://addons.mozilla.org/en-US/firefox/addon/firepath/  

SmartHome APP 使用教學

  當完成Gateway的授權後,可進入Gateway列表頁面                                       點擊綠色房子即可進入該Gateway內                                       顯示Gateway上所有的Device,Device分成兩類 一類為可控制類,如下                                       點擊後會跳出視窗顯示Device資訊控制元件                                       單點控制 UI Demo   單點控制 Demo   另一類為不可控制類                                       點擊後顯示該Device的狀態                                       點擊左下方Tab即可進入群組模式,點擊Plus圖示即可新增新群組                                       設定圖案、名稱及Device的動作                                       進行Device動作設定                                       完成群組設定                                       啟用群組模式                                       完成啟用                                         進入條件模式              

[Java] Timer - 每秒印一個log,測試service是否還活著

    void testMyScheduleDelayAndPeriod(){           Timer timer = new Timer();         System. out .println( "Delay:0秒, Period:1秒" );         System. out .println( "In testScheduleDelayAndPeriod:" + new Date());                  // schedule(TimerTask task, long delay, long period)         timer.schedule( new TimerTask() {              public void run() {                   System. out .println( "Task~ 執行時間:" + new Date());              }          }, 0, 1000);       }

電視直播

  TaiwanTV 線上直播︰ http://www.taiwantv.co/   SOPCAST︰ mac http://www.sopcast.com/cn/download/mac.html http://sopcast.en.softonic.com/mac   windows http://www.sopcast.com/download/win.html http://www.azofreeware.com/2007/11/sopcast-202.html   android http://www.sopcast.org/download/android.html   確定可以看的頻道︰ 年代新聞 sop://124.232.150.188:3920/5712   http://www.tvonlinestreams.com/sopcast-channel/ CCTV1 HD sop://124.232.150.188:3912/8893 CCTV3 HD sop://124.232.150.188:3912/6030 CCTV6 HD sop://124.232.150.188:3912/6032 CCTV8 HD sop://124.232.150.188:3912/6033 鳳凰資訊 sop://124.232.150.188:3912/8891 鳳凰衛視 HD sop://124.232.150.188:3912/8891 HKC1HD sop://46.246.89.189:3912/252605 Mifi.TV-1 sop://46.246.89.189:3912/146448 Mifi.TV-2 sop://46.246.89.189:3912/146449 ELTA體育 sop://124.232.150.188:3920/5691 民視 sop://124.232.150.188:3920/5692 台視 sop://124.232.150.188:3920/5696 大愛 sop://124.232.150.188:3920/5697 中視 sop://124.232.150.188:3920/5698 NAT sop://124.232.150.188:3920/5699 探索頻道