//
// VdieoViewController.swift
// BMI64-yjy
//
// Created by comsoft on 2025/12/04.
//
import UIKit
import AVKit
class VdieoViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func PlayVideo(_ sender: UIButton) {
let videoPath: String? = Bundle.main.path(forResource: "MBTI", ofType: "mp4")
let videoURL = URL(filePath: videoPath!)
let player = AVPlayer(url:videoURL)
let playerController = AVPlayerViewController()
playerController.player = player
present(playerController, animated: true)
player.play()
}
}
//
// ViewController.swift
// BMI64-yjy
//
// Created by comsoft on 2025/12/01.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var lblQuestion1: UILabel!
@IBOutlet weak var progressLabel: UILabel!
@IBOutlet weak var btn3: UIButton!
@IBOutlet weak var btn2: UIButton!
@IBOutlet weak var btn1: UIButton!
let questions = [
"Q1. 새로운 사람을 만나면 에너지가 난다",
"Q2. 세부사항보다 전체적인 그림이 더 중요하다",
"Q3. 결정보다 감정이 더 중요하다",
"Q4. 즉흥적 계획이 좋다"
]
var index = 0 // 현재 질문 번호
@IBAction func btnReset(_ sender: UIButton) {
resetTest()
}
// MBTI 점수
var e = 0; var iType = 0
var s = 0; var nType = 0
var t = 0; var f = 0
var j = 0; var p = 0
@IBAction func btnQ1(_ sender: UIButton) {
saveAnswer(isA: true)
}
@IBAction func btnQ1B(_ sender: UIButton) {
saveAnswer(isA: false)
}
func updateUI() {
lblQuestion1.text = questions[index]
progressLabel.text = "\(index + 1) / \(questions.count)"
}
override func viewDidLoad() {
super.viewDidLoad()
updateUI()
// Do any additional setup after loading the view.
let buttons = [btn1, btn2, btn3]
for btn in buttons {
btn?.layer.cornerRadius = 10
btn?.clipsToBounds = true // 둥근 모서리가 보이게 함
btn?.layer.borderWidth = 1 // 테두리 넣고 싶으면
btn?.layer.borderColor = UIColor.white.cgColor
}
}
func saveAnswer(isA: Bool) {
addScore(isA: isA)
nextQuestion()
}
// MBTI 점수 추가
func addScore(isA: Bool) {
switch index {
case 0: // E / I
if isA { e += 1 } else { iType += 1 }
case 1: // S / N
if isA { s += 1 } else { nType += 1 }
case 2: // T / F
if isA { t += 1 } else { f += 1 }
case 3: // J / P
if isA { j += 1 } else { p += 1 }
default:
break
}
}
func nextQuestion() {
if index < questions.count - 1 {
index += 1
updateUI()
} else {
finishTest()
}
}
func finishTest() {
let result =
"\(e >= iType ? "E" : "I")" +
"\(s >= nType ? "S" : "N")" +
"\(t >= f ? "T" : "F")" +
"\(j >= p ? "J" : "P")"
let alert = UIAlertController(title: "당신의 MBTI", message: result, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "확인", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
func resetTest() {
index = 0
e = 0
iType = 0
s = 0
nType = 0
t = 0
f = 0
j = 0
p = 0
updateUI()
}
}
//
// MBTIViewController.swift
// BMI64-yjy
//
// Created by comsoft on 2025/12/04.
//
import UIKit
import WebKit
class MBTIViewController: UIViewController {
@IBOutlet weak var goButton: UIButton!
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
guard let url1 = URL(string:"https://dunoning52.tistory.com") else { return }
let request = URLRequest(url: url1)
webView.load(request)
goButton.layer.cornerRadius = 10
goButton.clipsToBounds = true
}
@IBAction func goMBTI(_ sender: UIButton) {
guard let url = URL(string:"https://www.16personalities.com/ko/%EC%84%B1%EA%B2%A9-%EC%9C%A0%ED%98%95")else {return}
let request = URLRequest(url:url)
webView.load(request)
}
}
- Main.storyboard

- 각 controller 별 connection inspector



- 실행화면






- 앱 아이콘과 LanchScreen


'iOS' 카테고리의 다른 글
| iOS_3grade - 2주차 (0) | 2026.03.10 |
|---|---|
| iOS_3grade - 1주차 (1) | 2026.03.03 |
| iOS_week13 (1) | 2025.11.24 |
| iOS_week12 (0) | 2025.11.17 |
| iOS_week10 (0) | 2025.11.03 |