제목과 마찬가지로 Swift 3.0을 사용하여 Xcode 프로젝트를 작업하고 있습니다. 내 현재보기, 버튼 클릭에 대해 팝업으로 작은보기를 표시하고 싶습니다. 이 팝업은 많은 셀이 특정 배열에있는 경우 하나의 레이블 + 하나의 텍스트 상자를 표시하는 테이블 뷰입니다. 크기는 화면 조각으로 제한되며 테이블보기는 당연히 스크롤 할 수 있습니다.프로그래밍 방식으로 팝업으로 사용자 정의 테이블보기 만들기
프로그래밍 방식으로보기를 만드는 방법을 이해하고 "숨김 = true"개념을 얻었습니다. 정말 고민중인 것은 테이블 뷰를 얻는 것입니다. 이론적으로 스토리 보드에서 뷰를 디자인 할 수는 있지만 이름으로 참조하고 슈퍼 뷰를 현재 뷰에 적용 할 수있는 방법이 있습니까?
도움 주셔서 감사합니다.
편집 : 나는 지금까지이 코드로 가지고 도움을
감사합니다 :
@IBOutlet weak var CreatePost: UIButton!
@IBAction func CreatePost(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let popVC = storyboard.instantiateViewController(withIdentifier: "CreateAccountPop") // your viewcontroller's id
popVC.preferredContentSize = CGSize(width: 500, height: 600)
popVC.modalPresentationStyle = .popover
let popover = popVC.popoverPresentationController
popover?.delegate = self as? UIPopoverPresentationControllerDelegate
//sourceRect and sourceView is required in case of iPad
popover?.sourceRect = (sender as AnyObject).frame //give anchor frame
popover?.sourceView = sender as! UIView //give anchor view
self.present(popVC, animated: true, completion: nil)
}
코드는 뷰 컨트롤러를 표시하지만, 전체 화면을 차지합니다. 크기를 제한하는 방법을 파악할 수 없습니다.
을 UIPopoverPresentationControllerDelegate을 준수하는 것을 잊지 마세요? 보기 컨트롤러가 팝업으로 표시 될 수도 있습니다 –
그런 뜻입니까? https://developer.apple.com/ios/human-interface-guidelines/views/popovers/ – lukwuerz
예, 그런 것 같습니다. iPhone에서 팝업으로 제공됩니다. –