Swift 학습 노트 vol.01

10466 단어 SwiftiOS

개시하다


9월부터 스위프트가 시작됐다.
나는 공부하는 필기를 썼다.

학습물


Swift - Photo Gallery App (StoryBoard + Actions & Outlets) pt. 1/5
http://youtu.be/ztIBNHOm35E
https://github.com/TDAbboud/PhotosGalleryApp
  • 필기를 이해하기 어려우면 여기를 참조하십시오.
  • 이번 성과물



    이미지 갤러리를 만드는 첫걸음인 것 같아서요.

    인터페이스를 유판에 놓다


    ViewController 구성



    Navigation Controller 구성



    CollectionView를 PhotoCell로 정의



    CollectionView에서 PhotoCell로 정의된 ImageView 구성



    ImageView와 fullscreenView 연관



    쇼 선택

    NavigationItem을 View에 구성합니다.



    전체 화면으로 UIImageView 구성



    Coding


    ViewPhoto 클래스 만들기



    스트리밍 패널을 사용하여 ViewPort 클래스를 연결합니다.



    작업 연결이 구성된 버튼



    추가된 코드
    ViewPhoto.swift
    import UIKit
    
    class ViewPhoto: UIViewController {
    
        @IBAction func btnCancel(sender: AnyObject) {
            println("Cancel")
    
            self.navigationController?.popToRootViewControllerAnimated(true)
        }
    
    
        @IBAction func btnTrush(sender: AnyObject) {
            println("trush")
        }
    
        @IBAction func btnExport(sender: AnyObject) {
            println("Export")
        }
    
        @IBOutlet weak var ImgView: UIImageView!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Do any additional setup after loading the view.
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
    
    
    }
    
    
  • 부하 컨트롤러를 되돌려줍니다.
  • ViewController 코드와 연결합니다.



    ViewPhoto.swift
    import UIKit
    
    let reuseIdentifier = "PhotoCell"
    
    class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
    
        @IBOutlet var collectionView: UICollectionView!
    
        @IBAction func btnCamera(sender: AnyObject) {
        }
    
        @IBAction func btnPhotoAlbum(sender: AnyObject) {
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
        // uicollectionViewDataSource method
    
        func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
            return 1
        }
    
        // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
        func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
            let cell: UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as UICollectionViewCell
    
            // modify the cell
            cell.backgroundColor = UIColor.redColor()
    
            return cell
        }
    
    
    }  
    

    앞으로


    이번엔 파트1만 있고 앞으로도 계속 진행될 겁니다.

    좋은 웹페이지 즐겨찾기