iOS Swift Controller 실행 (Storyboard 실행)
AppDelegate.swift 파일에서..
아래와 같이 하면 앱을 시작하자마자 MainViewController.swift 파일이 호출된다.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = MainViewController()
return true
}
MainViewController.swift 파일에서 PhotoViewController.swift (PhotoView.storyboard 스토리보드 사용시) 파일을 호출시는..
userid 변수값에 값을 설정한다.
func goPhotoView(){
// PhotoView 스토리보드 이동
// https://zeddios.tistory.com/310
// https://g-y-e-o-m.tistory.com/43
let storyBoard = UIStoryboard.init(name: "PhotoView", bundle: nil)
let photoViewController = storyBoard.instantiateViewController(withIdentifier: "photoView") as! PhotoViewController
photoViewController.userid = "myUserid"
// photoViewController.delegate = self
present(photoViewController, animated: true, completion: nil)
}
PhotoViewController.swift 는.. userid 변수값을 받는다.
import UIKit
import MobileCoreServices
class PhotoViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIScrollViewDelegate {
// https://g-y-e-o-m.tistory.com/11
// https://stackoverflow.com/questions/51342028/cannot-subscript-a-value-of-type-string-any-with-an-index-of-type-uiimage
// https://stackoverflow.com/questions/51863259/swift-4-2-imagepickercontroller-issue
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
let imagePicker: UIImagePickerController! = UIImagePickerController()
var selectedImage: UIImage?
var flagImageSave = false
var userid : String = ""
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
scrollView.alwaysBounceVertical = false
scrollView.alwaysBounceHorizontal = false
scrollView.minimumZoomScale = 1.0
scrollView.maximumZoomScale = 3.0
scrollView.delegate = self
// 카메라 처음시작시 호출
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(openCamera), userInfo: nil, repeats: false)
}
@available(iOS 2.0, *)
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.imageView
}
@objc func openCamera(){
if(UIImagePickerController.isSourceTypeAvailable(.camera)){
flagImageSave = true
imagePicker.delegate = self
imagePicker.sourceType = .camera
imagePicker.mediaTypes = [kUTTypeImage as String]
imagePicker.allowsEditing = false
present(imagePicker, animated: true, completion: nil)
}
}
}
.
'iOS' 카테고리의 다른 글
iOS Swift 일정시간 지연후 실행, 타이머 (0) | 2019.06.11 |
---|---|
아이폰 아이콘에 뱃지 숫자 설정 (0) | 2019.06.07 |
iOS Swift 런치스크린 시간 고정(강제 지연) (0) | 2019.06.03 |
iOS Swift WKWebView 하이브리드앱에서 신용카드 결제 (0) | 2019.06.03 |
iOS Swift WKWebView 쿠키 유지 (0) | 2019.06.03 |