我正在快速处理Imessage应用程序。每当我向下滑动以从展开视图转到紧凑视图时,都会收到以下错误。 注意:它会进入紧凑视图,但在过渡时会冻结几秒钟,然后显示紧凑视图
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 Controller 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)
}
}