6

I am trying to import this project into my swift project. What I have done is add the PanoromaView.h and PanoromaView.m files, and added #import "PanoramaView.h" to my bridging header. I have also added the OpenGLES.framework and GLKit.Framework to my project.

I am now getting errors saying

Cannot find interface declaration for 'GLKView', superclass of 'PanoramaView'

and

Unknown type name 'GLKVector3'

This is an image of the errors in the code:

enter image description here

If anybody can help explain what these are how I remove them that would be great.

Thanks

EDIT:

I have also tried installing through Cocoapods and still get the exact same errors, very strange?

Henry Brown
  • 2,219
  • 8
  • 31
  • 48
  • You need to import whatever `PanoramaView` depends on. You should double check the source of those files and follow very closely the installation guidelines. – nhgrif May 08 '16 at 13:22
  • There are no installation guidelines, as you can see on the link. So I'm trying to work it out myself and I am stuck at this point. I thought I had importing everything it depends on I'm not sure what else is needed? – Henry Brown May 08 '16 at 13:25
  • Oh, well... it's a pod. Just use CocoaPods to install it? `pod 'PanoramaView'` – nhgrif May 08 '16 at 13:30
  • I have never used pods before but I will give this a try also then. Thanks – Henry Brown May 08 '16 at 13:34
  • @nhgrif I have now installed with CocoaPods but still get the exact same errors? Can you assist any further? – Henry Brown May 08 '16 at 15:07
  • Try to not use Parse. It's about to close. – Alexey Pelekh May 13 '16 at 14:39

1 Answers1

7

In order to make it work, I had to add this into PanoramaView.h:

#import <GLKit/GLKit.h>

Suggested on the github code does not work for me from the box. Also I had to modify ViewController:

import UIKit

class ViewController: GLKViewController {

    var panoramaView = PanoramaView()

    override func loadView() {
        panoramaView.setImageWithName("park_2048.jpg")
        panoramaView.touchToPan = true          // Use touch input to pan
        panoramaView.orientToDevice = false     // Use motion sensors to pan
        panoramaView.pinchToZoom = true         // Use pinch gesture to zoom
        panoramaView.showTouches = true         // Show touches
        self.view = panoramaView
    }

    override func glkView(view: GLKView, drawInRect rect: CGRect) {
        panoramaView.draw()
    }
}

This is my sample app:

https://github.com/melifaro-/Swift-PanoramaSample

Hope it helps.

BTW, I did not use CocoaPods. I use PanoramaView.h and PanoramaView.m files only.

Igor B.
  • 2,219
  • 13
  • 17
  • Thank you this is brilliant, just what I needed. I am not sure if you could also help me partially further. I want to be able to load the panoroma inside a view rather then a viewController? I know I have to use the GLKView but do you have any example code on this also would be great. thanks again – Henry Brown May 13 '16 at 15:12
  • Yep, sure. That won't be difficult. – Igor B. May 13 '16 at 15:28
  • Thank you, where will I find this? – Henry Brown May 13 '16 at 15:35
  • That shouldn't, but that is. I had to modify PanoramaView class itself. You can check out my sample on github. I have pushed changes there. – Igor B. May 13 '16 at 16:34
  • This isn't inside a GLKView, this is inside a GLKViewController? – Henry Brown May 15 '16 at 15:33
  • Oh Sorry I see what you have done now, Thanks for this - although I meant done programmatically, I do not like to use the IB... If you know how to do with just the code that would be great. – Henry Brown May 15 '16 at 15:45
  • Hmm, I don't know how to do that – Igor B. May 16 '16 at 11:21
  • Ok thanks for your help then. What you have created is a GLKViewController in the IB. Do you know how to add a GLKView through the IB rather then through code then? – Henry Brown May 16 '16 at 11:32
  • If my understanding is corrent you need both for correct work. Actually in the latest version there are presented both GLKViewController and GLKView (PanoramaView) in the storyboard file. – Igor B. May 16 '16 at 11:58
  • Yes but I want to be able to do is change the GLKViews frame size, what you have provided the view is embedded in the VC and the dimensions cannot be changed? – Henry Brown May 16 '16 at 12:03
  • Right, It occupies all the available space. Not sure how to change the GLKView frame size. – Igor B. May 16 '16 at 12:20