0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

練習のためにSwiftをUdemyで勉強してみた(1日目)

Posted at

まず、誰?

どこにでもいる社会人です。
普段、職場ではGASを使って仕事の効率化を図りながら日々を過ごしております。
もともとVBA、GASと業務効率化のためにプログラミングを行っておりましたが、職場内だけで使えるものではなくて、世界中の人が触れるものを作りたいとと思い、iPhoneアプリを作ろうと思い至りました。
なんでWebアプリじゃないのかって?
覚えることが多岐にわたって面倒くさそうだったので。
iPhoneアプリだったらとりあえずSwiftができればいいだろうと。
将来的にはWebアプリにも手を伸ばしていきたいです。

何で勉強するの?

Udemyの以下の講座を受講しました。
ちょうどセールで安かったので。

色々Swiftの言語の基本を学ぶよりかは、早速実物を作りたいと思い、実践重視のこれにしました。

【6日で速習】iOS 13アプリ開発入門決定版 20個のアプリを作って学ぼう(Xcode 11, Swift 5対応中)
https://www.udemy.com/course/ios11basics/

1日目

2つ作りました。

FirstMap

Swiftの使い方確認も兼ねて、単純にMap Kit Viewを配置しただけです。
プログラミングのプもしていませんw
後々、現在地を表示したり、指定の住所の地図を出せるようにしたいです。

FirstCamera

一気にコーディングしていったので、何が起きたのかよくわからないまま完成に至りましたw
あとでしっかりコードを読んで、何をしたのか把握したいです。
以下を記述したけど。。。

ViewController.swift
import UIKit

class ViewController: UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBOutlet weak var photoImage: UIImageView!
    
    @IBAction func cameraLaunchAction(_ sender: Any) {
        if UIImagePickerController.isSourceTypeAvailable(.camera){
            print("Camera can be usd.")
            let ipc = UIImagePickerController()
            ipc.sourceType = .camera
            ipc.delegate = self
            present(ipc,animated:true,completion:nil)
        }else{
            print("Camera is not avaiable.")
        }
    }
    
    @IBAction func shareAction(_ sender: Any) {
        if let sharedimage = photoImage.image{
            let sharedItems = [sharedimage]
            let controller = UIActivityViewController(activityItems: sharedItems, applicationActivities: nil)
            controller.popoverPresentationController?.sourceView = view
            present(controller,animated:true,completion: nil)
        }
    }
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        
        photoImage.image = info[UIImagePickerController.InfoKey.originalImage]as? UIImage
        dismiss(animated:true,completion: nil)
    }   
}

次にやること

  • 上記コードの内容を理解する
  • 次のアプリを作ってみる

がんばります。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?