呈现VC时出现InvalidPathValidation

时间:2018-02-14 23:59:58

标签: ios swift

所以我有一个viewController,它是在tableViewController的imageview中单击图像时显示的。我正在使用委托模式将当前单击的事件传递给我的表视图控制器,就像这样。这是创建委托和协议方法的tableViewCell。

import UIKit
protocol TransitionDelegate:NSObjectProtocol{
    func eventDetailTransition(currentEvent: Event)
}
class EventDetailsCell: UITableViewCell {
    weak var transitionDelegate:TransitionDelegate?
    var details:Event?{
        didSet{
            if let value = details?.currentEventName.uppercased(){
                labelDesciption.text = value
            }else{
                labelDesciption.text = "Uknown"
            }
            if let value = details?.currentEventDate{
                var dateString = ""
                dateString = "From "+value
                if let startTime = details?.currentEventTime{
                    dateString += ",\(startTime)"
                }
                if let end = details?.currentEventEndDate{
                    dateString += " to \(end)"
                }
                if let endTime = details?.currentEventEndTime{
                    dateString += ",\(endTime)"
                }
                labelDate.text = dateString
            }else{
                labelDate.text = "Uknown"
            }

            guard let url = URL(string: (details?.currentEventImage)!) else { return }
            eventImageView.af_setImage(withURL: url)
        }
    }

   @objc func eventDetailTransition(currentEvent: Event){
        print("View events button touched")
        if let delegate = self.transitionDelegate{
            delegate.eventDetailTransition(currentEvent: details!)
        }
    }
}

这是viewController,最终负责使用委托模式呈现eventDetailViewController。

class FriendsEventsView: UITableViewController,TransitionDelegate{
    var cellID = "cellID"
    var friends = [Friend]()
    var attendingEvents = [Event]()
    //label that will be displayed if there are no events
    var currentUserName: String?
    var currentUserPic: String?
    var currentEventKey: String?
    let currentEventDetailTransition = EventDetailViewController()

    func eventDetailTransition(currentEvent: Event) {
        print("Entered Table View")
        currentEventDetailTransition.currentEvent = currentEvent
        present(currentEventDetailTransition, animated: true, completion: nil)
    }

}

这是将要呈现的控制器的代码。

class EventDetailViewController: UIViewController {
    var imageURL: URL?
    //var activityIndicator: UIActivityIndicatorView?
    var currentEvent : Event?{
        didSet{
            imageURL = URL(string: (currentEvent?.currentEventImage)!)
            DispatchQueue.main.async {
                self.currentEventImage.af_setImage(withURL: self.imageURL!, placeholderImage: nil, filter: nil, progress: nil, progressQueue: .main, imageTransition: .crossDissolve(0.5), runImageTransitionIfCached: false, completion: { (response) in
                    let image = response.result.value // UIImage Object
                })
                self.blurryBackGround.af_setImage(withURL: self.imageURL!, placeholderImage: nil, filter: nil, progress: nil, progressQueue: .main, imageTransition: .crossDissolve(0.5), runImageTransitionIfCached: false, completion: { (response) in
                    let image = response.result.value // UIImage Object
                })
               // self.currentEventImage.af_setImage(withURL: self.imageURL!)
            }
            currentEventTime.text = currentEvent?.currentEventTime
            currentEventDate.text = currentEvent?.currentEventDate
            eventNameLabel.text = currentEvent?.currentEventName.uppercased()
            guard let currentZip = currentEvent?.currentEventZip else{
                return
            }
            let firstPartOfAddress = (currentEvent?.currentEventStreetAddress)!  + "\n" + (currentEvent?.currentEventCity)! + ", " + (currentEvent?.currentEventState)!
            let secondPartOfAddress = firstPartOfAddress + " " + String(describing: currentZip)
            addressLabel.text = secondPartOfAddress
            descriptionLabel.text = currentEvent?.currentEventDescription
            descriptionLabel.font = UIFont(name: (descriptionLabel.font?.fontName)!, size: 14)
            updateWithSpacing(lineSpacing: 7.0)
            navigationItem.title = currentEvent?.currentEventName.capitalized
            setupAttendInteraction()
        }

    override func viewDidLoad() {
        super.viewDidLoad()

        let downSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeAction(_:)))
        downSwipe.direction = .down
        view.addGestureRecognizer(downSwipe)
        view.backgroundColor = UIColor.white

        //Subviews will be added here
        view.addSubview(blurryBackGround)
        view.addSubview(currentEventImage)
        view.addSubview(currentEventDate)

        //Constraints will be added here
        _ = blurryBackGround.anchor(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, paddingTop: 17, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: self.view.frame.width, height: 330)
        blurryBackGround.addSubview(currentEventImage)
        currentEventImage.heightAnchor.constraint(equalToConstant: 330).isActive = true
        currentEventImage.widthAnchor.constraint(equalToConstant: 280).isActive = true
        currentEventImage.centerXAnchor.constraint(lessThanOrEqualTo:  currentEventImage.superview!.centerXAnchor).isActive = true
        currentEventImage.centerYAnchor.constraint(lessThanOrEqualTo: currentEventImage.superview!.centerYAnchor).isActive = true
        _ = currentEventDate.anchor(top: currentEventImage.bottomAnchor, left: stackView?.rightAnchor, bottom: nil, right: view.rightAnchor, paddingTop: -10, paddingLeft: 10, paddingBottom: 0, paddingRight: 0, width: 90, height: 50)
        setupEventDisplayScreen()
        userInteractionView()
    }
    }

我已经将代码修剪为重要的,只要呈现控制器和设置不同的变量就行了。

我不断得到这个我不太懂的消息

  

' InvalidPathValidation',原因:'(child :)必须是非空字符串且不包含'。' '#' ' $' ' ['或']''

0 个答案:

没有答案