Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLANK SCREEN WHEN USED WITH Swift #38

Open
hharanm opened this issue Apr 16, 2016 · 9 comments
Open

BLANK SCREEN WHEN USED WITH Swift #38

hharanm opened this issue Apr 16, 2016 · 9 comments

Comments

@hharanm
Copy link

hharanm commented Apr 16, 2016

All I Get Is A Blank Screen when the class's language is Swift

@fboulegue
Copy link
Contributor

@HarryKnowsTech did you find any solution for this i m stuck on the same point

@fboulegue
Copy link
Contributor

Here is a example for swift:

class MainView: GLKViewController {

    var panoramaView = PanoramaView()

    override func viewDidLoad() {
        panoramaView.setImage("eicccbbc.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()
    }
}

@fboulegue
Copy link
Contributor

#40 Updated readme with Swift example so might be closed by @robbykraft

@buiminhtu93
Copy link

HI, can you share Demo Project by Swift or Demo Detail Code? I write code like this but It don't run. It failt when start app. :( :( I don't know why???

This error at : "class AppDelegate: UIResponder, UIApplicationDelegate " of App Delegate
Help Me

@tscholze
Copy link

tscholze commented Feb 1, 2017

@buiminhtu93 do you get an error like reason: '-[GLKViewController loadView] loaded the "xxx" nib but didn't get a GLKView.'?

@smilesm2
Copy link

smilesm2 commented Feb 18, 2017

@tscholze I got this error too. I haven't find out any solution.
It crash at var panoramaView = PanoramaView()

@tscholze
Copy link

tscholze commented Mar 2, 2017

@smilesm2 what's your view controller type in your storyboard? You have to use GLKViewController.

@smilesm2
Copy link

@tscholze yes, finally I solved the problem.
The problem is it can't use normal view and put a GLKView even I connect all object and make sure all is ready.
I need to add a GLKViewController and everything is all right.

@mayakraft
Copy link
Owner

Thanks for all your help everyone! I want to update the documentation for swift integration. here's what I have.

  1. make sure you are using a GLKViewController instead of UIViewController
  2. contents of the GLKViewController:
import PanoramaView

class ViewController: GLKViewController {

	let panoramaView:PanoramaView

	required init?(coder aDecoder: NSCoder) {
		panoramaView = PanoramaView()
		super.init(coder: aDecoder)
	}

	override func viewDidLoad() {
		panoramaView.setImageWithName("park_2048.jpg")
		panoramaView.orientToDevice = true
//		panoramaView.touchToPan = false
//		... further customization
		self.view = panoramaView
	}

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

and that should be it, right, am I missing anything?

does anyone have best practices on creating the PanoaramaView as an optional and handling errors if it doesn't get created? I feel like it's better to declare let panoramaView:PanoramaView? instead of non-optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants