平成30年2月24日(土曜日)
XCODE Version 9.2
他のプロジェクトからfilecopy、file名だけ変更して安心していると、上記error
しっかりとclass名まで変更すべし、意外と「あるあるな件」
平成30年2月24日(土曜日)
XCODE Version 9.2
他のプロジェクトからfilecopy、file名だけ変更して安心していると、上記error
しっかりとclass名まで変更すべし、意外と「あるあるな件」
平成30年2月23日(金曜日)
SWIFT版
@IBAction func unwindToTop(segue: UIStoryboardSegue) {
}
これも、失念。
以下サイトにより、思い出す。
平成30年2月23日(金曜日)
久々のios googlemapsで地図が表示されない、何?っと思ったら、
そう、アプリケーションのIDを変更した時は、新たにKEYの取得が必要。
平成30年2月23日(金曜日)
LAYOUT関連
スクロールビュー、4面0設定、中に入るビューも同じく0設定とし、長さを幅を設定。
平成30年2月22日(木曜日)
セルに表示する画像の角丸化、以下サイトにより、OK!!
// 角丸にする cell.img.layer.cornerRadius = cell.img.frame.size.width * 0.2 cell.img.clipsToBounds = true
平成30年2月21日(水曜日)
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: CustomCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomCell
if let data = tabledata {
let urlString: NSString = data.results[indexPath.row].artworkUrl60 as NSString
let imgURL: URL = URL(string: urlString as String)!
do {
let imageData = try Data(contentsOf: imgURL as URL)
cell.img.image = UIImage(data: imageData)
} catch {
print("Unable to load data: \(error)")
}
}
return cell
}
平成30年2月21日(水曜日)
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
}
平成30年2月21日(水曜日)
import UIKit
class TableViewController: UITableViewController {
//配列fruitsを設定
let fruits = ["apple", "orange", "melon", "banana", "pineapple"]
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return fruits.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
// セルに表示する値を設定する
cell.textLabel!.text = fruits[indexPath.row]
return cell
}
}
平成30年2月21日(水曜日)
BASIC -> AppDelegate
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "TableViewController")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
return true
}
}
平成30年2月19日(火曜日)
var a = [1, 2, 3]
for value in a {
print(value) // 1, 2, 3
}
// インデックス付き
for (i, value) in a.enumerated() {
print(i) // 0, 1, 2
print(value) // 1, 2, 3
}
// nil 以外の要素をループ
var a: [String?] = ["1", nil, "2"]
for case let value? in a {
print(value) // "1", "2"
}