2016-01-01から1ヶ月間の記事一覧
"View Controller" 項目の "Initial Scene" の "Is Initial View Controller”をチェックで復活。
AppDelegate.swiftとは? アプリをつくった段階でデフォルトでつくられるファイルのひとつ。 アプリ全体のライフタイムイベントを管理するためのクラス。 http://qiita.com/SoyaTakahashi/items/cc8f48af792c353cd9f3共通関数やら変数をページ越しで管理する…
@IBAction func closeTapped(){ self.dismissViewControllerAnimated(true, completion: nil); }
let query = "ニュース"; let encoded = query.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) let url = "https://ajax.googleapis.com/ajax/services/search/news?v=1.0&hl=ja&rsz=8&q=" + encoded!;…
<b>タグを抜く例 var title = newsDic["title"] as? String; title = title?.stringByReplacingOccurrencesOfString("<b>", withString: ""); title = title?.stringByReplacingOccurrencesOfString("</b>", withString: "");</b>
プロジェクトアイコンをクリックして、設定画面から「Info」のタブ [+] App Transport Security Settings を追加 その中に、[+] Allow Arbitrary Loads で Boolean を True
世界一受けたいiphoneアプリの授業から転載 import UIKit import Alamofire class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate { @IBOutlet var table: UITableView! var newsDataArray = NSArray(); func tableView(table…
Download https://github.com/Alamofire/Alamofire Download後、[Alamofire.xcodeproj]をライブラリメニューにペースト setting general > embed Binary で[+]で追加。 [Alamofile iOS]を選択して追加 code let requestUrl = "https://ajax.googleapis.com/…
var transform:CGAffineTransform = CGAffineTransformIdentity let duration:Double = 0.5 transform = CGAffineTransformMakeRotation(CGFloat(0.25*M_PI)) UIView.animateWithDuration(duration,animations:{()-> Void in sender.transform = transform }…
performSegueWithIdentifier("hoge", sender: nil)
import UIKit import QuartzCore ... let gradient = CAGradientLayer(); gradient.frame = button.bounds; let arryColors = [ colorWithRGBHex(0xFFFFFF,alpha:1.0).CGColor as AnyObject, colorWithRGBHex(0xCCCCCC,alpha:1.0).CGColor as AnyObject ]; g…
let screenWidth:Double = Double(UIScreen.mainScreen().bounds.size.width) let screenHeight:Double = Double(UIScreen.mainScreen().bounds.size.height)
func colorWithRGBHex(hex:Int,alpha: Float = 1.0) -> UIColor{ let r = Float((hex >> 16) & 0xFF); let g = Float((hex >> 8) & 0xFF); let b = Float((hex ) & 0xFF); return UIColor( red: CGFloat(r / 255.0), green: CGFloat(g / 255.0), blue: CGFlo…
func loadCSV(filename: String) -> [String] { let csvBundle = NSBundle.mainBundle().pathForResource(filename, ofType: "csv"); var csvArray:Array<String> = []; do { let csvData = try String(contentsOfFile: csvBundle!, encoding: NSUTF8StringEncoding)</string>…
import Foundation import AVFoundation class SEManager: NSObject,AVAudioPlayerDelegate{ var soundArray = [AVAudioPlayer]() func sePlay(soundName: String ,loop: Bool){ let url = NSBundle.mainBundle().bundleURL.URLByAppendingPathComponent(sou…
var cacheKey:String = "dataKey"; let userData = NSUserDefaults.standardUserDefaults(); value:Int = userData.integerForKey(cacheKey); userData.setInteger(value+1, forKey: cacheKey) print("value:\(value)");
import Social... @IBAction func postTwitter(sender:AnyObject){ let twVC:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)! twVC.setInitialText("twにつぶやく文章"); twVC.addImage(UIImage(named:"icon.png…