Skip to content

Commit

Permalink
[#68] 화면 전환 실습
Browse files Browse the repository at this point in the history
  • Loading branch information
Taehyeon-Kim committed Jul 22, 2022
1 parent 22c5854 commit 3e96f52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ class RecommendCollectionViewController: UICollectionViewController {

static let identifier = "RecommendCollectionViewController"
let imageURL = "https://img1.daumcdn.net/thumb/R1280x0/?fname=http://t1.daumcdn.net/brunch/service/user/wXP/image/6j8FvDZzIaPickhD9G5IR-u7yGc.png"

// 1. 값 전달 - 데이터를 받을 공간(프로퍼티) 생성
var movieTitle: String?

override func viewDidLoad() {
super.viewDidLoad()

// 3. 값 전달 - 프로퍼티 값을 뷰에 표현
self.title = self.movieTitle == nil ? "데이터 없음" : movieTitle!

let layout = UICollectionViewFlowLayout()
let spacing: CGFloat = 8
let width = UIScreen.main.bounds.width - (spacing * 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ final class SearchTableViewController: UITableViewController {
let storyboard = UIStoryboard(name: "Trend", bundle: nil)
let viewController = storyboard.instantiateViewController(identifier: RecommendCollectionViewController.identifier) as! RecommendCollectionViewController

// 2. 값 전달 - vc가 가지고 있는 프로퍼티에 데이터 추가
viewController.movieTitle = self.movieInfo.movie[indexPath.row].title

self.navigationController?.pushViewController(viewController, animated: true)
}
}

0 comments on commit 3e96f52

Please sign in to comment.