present DocumentInteractionController inside tableview XIB containing a collectionView









up vote
1
down vote

favorite












Im trying to load a tableview xib containing a collectionView. collectionView contains a list of files as to be downloaded and opened.



class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate {

var dic = UIDocumentInteractionController()
var imgCollection: [TicketAttachment] = [TicketAttachment]()
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var imgProfilePic: UIImageView!
@IBOutlet weak var lblName: UILabel!
@IBOutlet weak var lblDate: UILabel!
@IBOutlet weak var txvComments: UITextView!
override func awakeFromNib()
super.awakeFromNib()
dic.delegate = self
self.collectionView.dataSource = self
self.collectionView.delegate = self
self.collectionView.register(UINib.init(nibName: "AttachmentViewCell", bundle: nil), forCellWithReuseIdentifier: "AttachmentViewCell")



func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
let url = URL(string: Api.domain + fileUrl!)

let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

sharedAFManager.AFManager.download(url!, to: destination)
.downloadProgress(closure: _ in
SVProgressHUD.show()
).response(completionHandler: (downloadResponse) in
SVProgressHUD.dismiss()
self.dic.url = downloadResponse.destinationURL
self.dic.uti = downloadResponse.destinationURL!.uti
let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
)




self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
Value of type 'CommentsCell' has no member 'view'




Tableview XIB design:



Tableview XIB design file










share|improve this question



























    up vote
    1
    down vote

    favorite












    Im trying to load a tableview xib containing a collectionView. collectionView contains a list of files as to be downloaded and opened.



    class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate {

    var dic = UIDocumentInteractionController()
    var imgCollection: [TicketAttachment] = [TicketAttachment]()
    @IBOutlet weak var collectionView: UICollectionView!
    @IBOutlet weak var imgProfilePic: UIImageView!
    @IBOutlet weak var lblName: UILabel!
    @IBOutlet weak var lblDate: UILabel!
    @IBOutlet weak var txvComments: UITextView!
    override func awakeFromNib()
    super.awakeFromNib()
    dic.delegate = self
    self.collectionView.dataSource = self
    self.collectionView.delegate = self
    self.collectionView.register(UINib.init(nibName: "AttachmentViewCell", bundle: nil), forCellWithReuseIdentifier: "AttachmentViewCell")



    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
    let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
    let url = URL(string: Api.domain + fileUrl!)

    let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

    sharedAFManager.AFManager.download(url!, to: destination)
    .downloadProgress(closure: _ in
    SVProgressHUD.show()
    ).response(completionHandler: (downloadResponse) in
    SVProgressHUD.dismiss()
    self.dic.url = downloadResponse.destinationURL
    self.dic.uti = downloadResponse.destinationURL!.uti
    let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
    self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
    )




    self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
    Value of type 'CommentsCell' has no member 'view'




    Tableview XIB design:



    Tableview XIB design file










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Im trying to load a tableview xib containing a collectionView. collectionView contains a list of files as to be downloaded and opened.



      class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate {

      var dic = UIDocumentInteractionController()
      var imgCollection: [TicketAttachment] = [TicketAttachment]()
      @IBOutlet weak var collectionView: UICollectionView!
      @IBOutlet weak var imgProfilePic: UIImageView!
      @IBOutlet weak var lblName: UILabel!
      @IBOutlet weak var lblDate: UILabel!
      @IBOutlet weak var txvComments: UITextView!
      override func awakeFromNib()
      super.awakeFromNib()
      dic.delegate = self
      self.collectionView.dataSource = self
      self.collectionView.delegate = self
      self.collectionView.register(UINib.init(nibName: "AttachmentViewCell", bundle: nil), forCellWithReuseIdentifier: "AttachmentViewCell")



      func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
      let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
      let url = URL(string: Api.domain + fileUrl!)

      let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

      sharedAFManager.AFManager.download(url!, to: destination)
      .downloadProgress(closure: _ in
      SVProgressHUD.show()
      ).response(completionHandler: (downloadResponse) in
      SVProgressHUD.dismiss()
      self.dic.url = downloadResponse.destinationURL
      self.dic.uti = downloadResponse.destinationURL!.uti
      let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
      self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
      )




      self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
      Value of type 'CommentsCell' has no member 'view'




      Tableview XIB design:



      Tableview XIB design file










      share|improve this question















      Im trying to load a tableview xib containing a collectionView. collectionView contains a list of files as to be downloaded and opened.



      class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate {

      var dic = UIDocumentInteractionController()
      var imgCollection: [TicketAttachment] = [TicketAttachment]()
      @IBOutlet weak var collectionView: UICollectionView!
      @IBOutlet weak var imgProfilePic: UIImageView!
      @IBOutlet weak var lblName: UILabel!
      @IBOutlet weak var lblDate: UILabel!
      @IBOutlet weak var txvComments: UITextView!
      override func awakeFromNib()
      super.awakeFromNib()
      dic.delegate = self
      self.collectionView.dataSource = self
      self.collectionView.delegate = self
      self.collectionView.register(UINib.init(nibName: "AttachmentViewCell", bundle: nil), forCellWithReuseIdentifier: "AttachmentViewCell")



      func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
      let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
      let url = URL(string: Api.domain + fileUrl!)

      let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

      sharedAFManager.AFManager.download(url!, to: destination)
      .downloadProgress(closure: _ in
      SVProgressHUD.show()
      ).response(completionHandler: (downloadResponse) in
      SVProgressHUD.dismiss()
      self.dic.url = downloadResponse.destinationURL
      self.dic.uti = downloadResponse.destinationURL!.uti
      let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
      self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
      )




      self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
      Value of type 'CommentsCell' has no member 'view'




      Tableview XIB design:



      Tableview XIB design file







      ios swift uitableview uidocumentinteractioncontroller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 10:16









      Sateesh

      1,7181715




      1,7181715










      asked Nov 12 at 7:33









      Vaisakh Kp

      3810




      3810






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Pass viewController object to UITableViewCell and replace line with



          self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)


          In ViewController:



          func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

          .....
          cell.vc = self



          In CommentsCell:



          class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate 

          weak var vc: UIViewController!

          ........

          func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
          let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
          let url = URL(string: Api.domain + fileUrl!)

          let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

          sharedAFManager.AFManager.download(url!, to: destination)
          .downloadProgress(closure: _ in
          SVProgressHUD.show()
          ).response(completionHandler: (downloadResponse) in
          SVProgressHUD.dismiss()
          self.dic.url = downloadResponse.destinationURL
          self.dic.uti = downloadResponse.destinationURL!.uti
          let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
          self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)
          )







          share|improve this answer



























            up vote
            0
            down vote













            You can not presentOpenInMenu from UIView. You need to use UIviewContoller's instance to Present ViewController so You can simply Pass View Controller object in tableview cell or use below Extension of uiview



            extension UIView 

            var parentViewController: UIViewController?
            var parentResponder: UIResponder? = self
            while parentResponder != nil
            parentResponder = parentResponder!.next
            if let viewController = parentResponder as? UIViewController
            return viewController


            return nil





            and presentOpenInMenu like



            self.parentViewController?.presentOpenInMenu(from: rect, in: self.view, animated: true)





            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257613%2fpresent-documentinteractioncontroller-inside-tableview-xib-containing-a-collecti%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote



              accepted










              Pass viewController object to UITableViewCell and replace line with



              self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)


              In ViewController:



              func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

              .....
              cell.vc = self



              In CommentsCell:



              class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate 

              weak var vc: UIViewController!

              ........

              func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
              let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
              let url = URL(string: Api.domain + fileUrl!)

              let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

              sharedAFManager.AFManager.download(url!, to: destination)
              .downloadProgress(closure: _ in
              SVProgressHUD.show()
              ).response(completionHandler: (downloadResponse) in
              SVProgressHUD.dismiss()
              self.dic.url = downloadResponse.destinationURL
              self.dic.uti = downloadResponse.destinationURL!.uti
              let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
              self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)
              )







              share|improve this answer
























                up vote
                0
                down vote



                accepted










                Pass viewController object to UITableViewCell and replace line with



                self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)


                In ViewController:



                func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

                .....
                cell.vc = self



                In CommentsCell:



                class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate 

                weak var vc: UIViewController!

                ........

                func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
                let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
                let url = URL(string: Api.domain + fileUrl!)

                let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

                sharedAFManager.AFManager.download(url!, to: destination)
                .downloadProgress(closure: _ in
                SVProgressHUD.show()
                ).response(completionHandler: (downloadResponse) in
                SVProgressHUD.dismiss()
                self.dic.url = downloadResponse.destinationURL
                self.dic.uti = downloadResponse.destinationURL!.uti
                let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
                self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)
                )







                share|improve this answer






















                  up vote
                  0
                  down vote



                  accepted







                  up vote
                  0
                  down vote



                  accepted






                  Pass viewController object to UITableViewCell and replace line with



                  self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)


                  In ViewController:



                  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

                  .....
                  cell.vc = self



                  In CommentsCell:



                  class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate 

                  weak var vc: UIViewController!

                  ........

                  func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
                  let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
                  let url = URL(string: Api.domain + fileUrl!)

                  let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

                  sharedAFManager.AFManager.download(url!, to: destination)
                  .downloadProgress(closure: _ in
                  SVProgressHUD.show()
                  ).response(completionHandler: (downloadResponse) in
                  SVProgressHUD.dismiss()
                  self.dic.url = downloadResponse.destinationURL
                  self.dic.uti = downloadResponse.destinationURL!.uti
                  let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
                  self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)
                  )







                  share|improve this answer












                  Pass viewController object to UITableViewCell and replace line with



                  self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)


                  In ViewController:



                  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

                  .....
                  cell.vc = self



                  In CommentsCell:



                  class CommentsCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UIDocumentInteractionControllerDelegate 

                  weak var vc: UIViewController!

                  ........

                  func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
                  let fileUrl = imgCollection[indexPath.row].fileUrl?.absoluteString
                  let url = URL(string: Api.domain + fileUrl!)

                  let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)

                  sharedAFManager.AFManager.download(url!, to: destination)
                  .downloadProgress(closure: _ in
                  SVProgressHUD.show()
                  ).response(completionHandler: (downloadResponse) in
                  SVProgressHUD.dismiss()
                  self.dic.url = downloadResponse.destinationURL
                  self.dic.uti = downloadResponse.destinationURL!.uti
                  let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
                  self.dic.presentOpenInMenu(from: rect, in: vc.view, animated: true)
                  )








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 at 7:37









                  Sateesh

                  1,7181715




                  1,7181715






















                      up vote
                      0
                      down vote













                      You can not presentOpenInMenu from UIView. You need to use UIviewContoller's instance to Present ViewController so You can simply Pass View Controller object in tableview cell or use below Extension of uiview



                      extension UIView 

                      var parentViewController: UIViewController?
                      var parentResponder: UIResponder? = self
                      while parentResponder != nil
                      parentResponder = parentResponder!.next
                      if let viewController = parentResponder as? UIViewController
                      return viewController


                      return nil





                      and presentOpenInMenu like



                      self.parentViewController?.presentOpenInMenu(from: rect, in: self.view, animated: true)





                      share|improve this answer
























                        up vote
                        0
                        down vote













                        You can not presentOpenInMenu from UIView. You need to use UIviewContoller's instance to Present ViewController so You can simply Pass View Controller object in tableview cell or use below Extension of uiview



                        extension UIView 

                        var parentViewController: UIViewController?
                        var parentResponder: UIResponder? = self
                        while parentResponder != nil
                        parentResponder = parentResponder!.next
                        if let viewController = parentResponder as? UIViewController
                        return viewController


                        return nil





                        and presentOpenInMenu like



                        self.parentViewController?.presentOpenInMenu(from: rect, in: self.view, animated: true)





                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          You can not presentOpenInMenu from UIView. You need to use UIviewContoller's instance to Present ViewController so You can simply Pass View Controller object in tableview cell or use below Extension of uiview



                          extension UIView 

                          var parentViewController: UIViewController?
                          var parentResponder: UIResponder? = self
                          while parentResponder != nil
                          parentResponder = parentResponder!.next
                          if let viewController = parentResponder as? UIViewController
                          return viewController


                          return nil





                          and presentOpenInMenu like



                          self.parentViewController?.presentOpenInMenu(from: rect, in: self.view, animated: true)





                          share|improve this answer












                          You can not presentOpenInMenu from UIView. You need to use UIviewContoller's instance to Present ViewController so You can simply Pass View Controller object in tableview cell or use below Extension of uiview



                          extension UIView 

                          var parentViewController: UIViewController?
                          var parentResponder: UIResponder? = self
                          while parentResponder != nil
                          parentResponder = parentResponder!.next
                          if let viewController = parentResponder as? UIViewController
                          return viewController


                          return nil





                          and presentOpenInMenu like



                          self.parentViewController?.presentOpenInMenu(from: rect, in: self.view, animated: true)






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 12 at 7:44









                          Jatin Kathrotiya

                          376110




                          376110



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257613%2fpresent-documentinteractioncontroller-inside-tableview-xib-containing-a-collecti%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              27

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              Category:Rhetoric