0

주 viewController를 가지고 있는데 여기에는 사용자 정의 tableViewCell이있는 tableView가 있습니다. 그 안에는 몇 개의 뷰 객체와 버튼이 추가되어 있습니다. 셀의 단추를 클릭 할 때 또 다른 ViewController를 제시하고 또한 클릭 이벤트가 발생한 tableCell 데이터를 보내야합니다. 그리고 PickerView 및 다른 레이블의 텍스트에서 선택된 값을받습니다. 닫기 버튼과 같은 방법이 필요합니다. 나는 내가 팝 오버 컨트롤러에 해당 셀의 데이터를로드와로 제시하려고 다음 코드 다음Popover로 ViewController 제시

@IBAction func cellBtnClicked(_ sender: Any) { 
    let foodItem:FoodItem? 
    let indexPath : IndexPath 
    if let button = sender as? UIButton { 
     let cell = button.superview?.superview as! UITableViewCell 
     indexPath = self.tableView.indexPath(for: cell)! 
     let hotel = hotels[indexPath.section] 
     foodItem = hotel.menu[indexPath.row] 

를 사용하여 클릭 이벤트가 셀에서 발생한 셀의 데이터를 보낼 수 있어요

팝 오버

let popoverContent = self.storyboard?.instantiateViewController(withIdentifier:"ShowPopoverVC") as! MiniCartVC 
     popoverContent.foodItem = foodItem 
     popoverContent.modalPresentationStyle = UIModalPresentationStyle.popover 

       if let popover = popoverContent.popoverPresentationController { 

        let viewForSource = sender as! UIView 
        popover.sourceView = viewForSource 

        // the position of the popover where it's showed 
        popover.sourceRect = viewForSource.bounds 

        // the size you want to display 
        popoverContent.preferredContentSize = CGSize(width: 200, height: 135) 
        popover.delegate = self 
       }    

       self.present(popoverContent, animated: true, completion: nil) 
    } 

그러나 내가 그것을 기각시 MainVC에 팝 오버의 VC에서 데이터를 전송하는 방법이 필요 전체 View.Also을 확대하고, 대신에 SEGUE 같은 팝 오버로 오는되지 않습니다.

올바르게 구현할 방법이 있는지 알려 주시기 바랍니다. 참조 목적으로 사용되는 리소스도 괜찮습니다. 감사합니다. 당신 나열된 코드에서

+0

여기 팝 오버 튜토리얼입니다 - -> https://www.youtube : 그냥이 구현에게 (UIPresentationController 컨트롤러)

FUNC의 adaptivePresentationStyle을 선택하는 방법을 구현하고 사용합니다. co.kr/watch? v = 48UA06EwfrM. 또한 대리자 패턴을 사용하여 Popover에서 부모보기 컨트롤러로 데이터를 보내려고합니다. http://useyourloaf.com/blog/quick-guide-to-swift-delegates/ – Adrian

답변

0

: 당신은 자기가되도록 UIPopoverPresentationControllerDelegate을 설정 한

popover.delegate = self 

. > UIModalPresentationStyle { 반환 .none }

+0

옵션 기능이 포함되어 있습니다. –

+0

실제로 당신의 아이디어가 저에게 효과적이었습니다. 내 다음 코드를 변경 한 'adaptivePresentationStyleForPresentationController FUNC (컨트롤러 : UIPresentationController) -> UIModalPresentationStyle { 반환 .none }'으로 ----> 'adaptivePresentationStyle FUNC (컨트롤러 : UIPresentationController) -> UIModalPresentationStyle { 반환 UIModalPresentationStyle.none } '감사합니다. –

+0

친절하게도 도움이 되었다면 투표하십시오. 다른 사용자에게도 도움이됩니다. 감사합니다. . – soumil