This site has been archived and remains strictly as a historical reference for developers who actively maintain apps built using the legacy Google VR SDK, which was last updated in 2019 and is no longer receiving updates.
  • All developers actively developing experiences for Google Cardboard should use the new open source Cardboard SDKs for iOS, Android NDK, and Unity XR Plugin. These new SDKs offer streamlined APIs, improved device compatibility, and built-in viewer profile QR code scanning.
  • The Daydream View VR headset is no longer available for purchase as of October 15, 2019. Existing apps on supported devices are unaffected for users who previously installed those applications. It is no longer possible to opt-in to Daydream distribution via Google Play.

GVRCardboardView Class

Stay organized with collections Save and categorize content based on your preferences.
GVRCardboardView Class Reference


Defines a view responsible for rendering graphics in VR mode.

It is designed to work in full screen mode with a landscape orientation. It provides all the transition between mono and stereo (VR) modes. The view switches to fullscreen VR mode when vrModeEnabled property is set to YES. The developer should ensure UISupportedInterfaceOrientations key in the application's plist file includes UIInterfaceOrientationPortrait and UIRequiresFullscreen is set to YES.

The users of this class provide an implementation of the GVRCardboardViewDelegate protocol through the delegate property. The methods in the protocol GVRCardboardViewDelegate are called to perform the actual rendering of the graphics.

In order to drive the rendering, the users of this class should call the render method from their render loop. The thread used to call the render method is refered to as the GL thread. This thread, in turn, calls the method of the GVRCardboardViewDelegate protocol.

Inherits UIView.

Instance Method Summary

(instancetype) - initWithFrame:
 Designated initializer. More...
(void) - render
 Drives the rendering of the cardboard view. More...

Class Method Summary

(void) + setViewerParamsFromUrl:withCompletion:
 Sets the Cardboard viewer parameters from a Url. More...

Property Summary

id< GVRCardboardViewDelegatedelegate
 Delegate to be notified of cardboard view rendering. More...
EAGLContext * context
 The OpenGL context used for rendering. More...
BOOL vrModeEnabled
 The vrModeEnabled property allows switching to and from VR mode. More...
BOOL hidesTransitionView
 Flag to hide or show the transition view when in VR mode. More...

Method Detail

- (instancetype) initWithFrame: (CGRect)  NS_DESIGNATED_INITIALIZER

Designated initializer.

- (void) render

Drives the rendering of the cardboard view.

Call this from your app's render loop.

+ (void) setViewerParamsFromUrl: (NSURL *)  url
withCompletion: (void(^)(BOOL success, NSError *error))  completion 

Sets the Cardboard viewer parameters from a Url.

This allows programmatically pairing a viewer without having the user go through the pairing flow. Calls the supplied completion handler with the result of pairing and the error if it fails.

Note: The viewer parameters can be set only if no other viewer pairing exists. In other words, this only works if the user hasn't already paired a viewer for the current application.

A valid viewer parameters URI can be generated from this page:

Property Detail

- (id<GVRCardboardViewDelegate>) delegate

Delegate to be notified of cardboard view rendering.

- (EAGLContext*) context

The OpenGL context used for rendering.

Defaults to OpenGL ES3 context, if not set.

- (BOOL) vrModeEnabled

The vrModeEnabled property allows switching to and from VR mode.

When set to YES, the cardboard view transitions into a fullscreen view to allow the user to place the device into the Cardboard viewer. When set to NO, it transitions back to pre-VR (mono) mode.

- (BOOL) hidesTransitionView

Flag to hide or show the transition view when in VR mode.