Переход обратно в Compact View в Swift дает ошибку Bounding Path of sync Error - PullRequest
0 голосов
/ 08 декабря 2018

Я работаю над приложением Imessage в swift.Всякий раз, когда я провожу пальцем вниз, чтобы перейти от расширенного вида к компактному, я получаю следующую ошибку.ПРИМЕЧАНИЕ: он переходит к компактному представлению, но при переходе он останавливается на несколько секунд, а затем представляет компактное представление

Bounding path likely out of sync with its coordinate space: The view's bounds must contain the bounding rect. Bounding rect: {{0, 0}, {414, 646}}; coordinate space: <_UIHostedWindow: 0x101200120; frame = (0 0; 414 267); gestureRecognizers = <NSArray: 0x281357cc0>; layer 
= <UIWindowLayer: 0x281d50d40>>

На данный момент это копия моего кода, у меня есть 2 View Controllers Compact и другиеExpandedVC

    override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
        // Called before the extension transitions to a new presentation style.

        // Use this method to prepare for the change in presentation style.
        removeAllChildViewControllers()
    }

    override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
        // Called after the extension transitions to a new presentation style.

        // Use this method to finalize any behaviors associated with the change in presentation style.
        super.didTransition(to: presentationStyle)

        guard let conversation = activeConversation else { fatalError("Expected an active converstation") }
        presentViewController(for: conversation, with: presentationStyle)
    }


    private func presentViewController(for conversation: MSConversation, with presentationStyle: MSMessagesAppPresentationStyle)
    {

        removeAllChildViewControllers()
        dismiss(animated: true, completion: nil)

        let controller:UIViewController

        if presentationStyle == .compact
        {
            //dismiss(animated: false, completion: nil)
            controller = compactVC()
            print("compact")
            present(controller,animated: false)
        }
        else if presentationStyle == .expanded
        {
            //dismiss(animated: false, completion: nil)
            print("expanded")
            controller = expandedVCfunc()
            present(controller,animated: false)
        }

    }



    private func compactVC() -> UIViewController {
        guard let compactView = storyboard?.instantiateViewController(withIdentifier: "compact")
            as? MessagesViewController
            else { fatalError("Unable to instantiate an IceCreamsViewController from the storyboard") }

        //compactView.delegate = self

        return compactView
    }

    private func expandedVCfunc() -> UIViewController {
        guard let expandedView = storyboard?.instantiateViewController(withIdentifier: "expanded")
            as? ExpandedVC
            else { fatalError("Unable to instantiate an IceCreamsViewController from the storyboard") }

        //compactView.delegate = self

        return expandedView
    }


    // MARK: Convenience

    private func removeAllChildViewControllers() {
        for child in children {
            child.willMove(toParent: nil)
            child.view.removeFromSuperview()
            child.removeFromParent()
        }
    }









}

extension MessagesViewController: UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource
{

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

       //omg()
        return myList.count
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {


        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Cell
        cell.cellLabel.text! = myList[indexPath.row]

        return cell
    }


    func contactsFunc()-> [String]{
    store.requestAccess(for: .contacts) { (accessStatus, error) in

    if let error = error{
    print("failed")
    return
    }

    if accessStatus
    {
    print("Access Granted")

    let keys = [CNContactGivenNameKey,CNContactImageDataKey]
    let request = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor])
    do
    {
    try self.store.enumerateContacts(with: request, usingBlock: { (contact, stopPointerEnumerating) in

        self.dataModel.contactArray.append(contact.givenName)




    //self.collectionView.reloadData()
    })

    }
    catch{
    print("failed in catch")
    }

    }
    else
    {
    print("Denied")
    }
        }
        myList = self.dataModel.contactArray
        print(self.dataModel.contactArray)
        return myList
        //print(self.dataModel.contactName)

    }










    }
...