# GVRCardboardView Class

[Instance Methods](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#pub-methods) \| [Class Methods](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#pub-static-methods) \| [Properties](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#properties) GVRCardboardView Class Reference

## Overview

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 `https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a9d184749c1056438ed60c94b938c725c` 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 `https://developers.google.com/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p` protocol through the `delegate` property. The methods in the protocol `https://developers.google.com/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p` 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 `https://developers.google.com/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p` protocol.

Inherits UIView.

|---|---|
| ## Instance Method Summary ||
| (instancetype) | - [initWithFrame:](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#ab9d997e071c75cc004aba36df6334561) |
|   | Designated initializer. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#ab9d997e071c75cc004aba36df6334561) |
|   ||
| (void) | - [render](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a772ea7d00ef72f128416da33d006c4ea) |
|   | Drives the rendering of the cardboard view. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a772ea7d00ef72f128416da33d006c4ea) |
|   ||

|---|---|
| ## Class Method Summary ||
| (void) | + [setViewerParamsFromUrl:withCompletion:](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a053783e64400204a31340fe1a1da6303) |
|   | Sets the Cardboard viewer parameters from a Url. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a053783e64400204a31340fe1a1da6303) |
|   ||

|---|---|
| ## Property Summary ||
| id\< [GVRCardboardViewDelegate](https://developers.google.com/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p) \> | [delegate](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a91b10566ba33a3c952730ade32ec8c1d) |
|   | Delegate to be notified of cardboard view rendering. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a91b10566ba33a3c952730ade32ec8c1d) |
|   ||
| EAGLContext \* | [context](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#afa901c9714cbe5271f8e487c16aa9afb) |
|   | The OpenGL context used for rendering. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#afa901c9714cbe5271f8e487c16aa9afb) |
|   ||
| BOOL | [vrModeEnabled](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a9d184749c1056438ed60c94b938c725c) |
|   | The vrModeEnabled property allows switching to and from VR mode. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a9d184749c1056438ed60c94b938c725c) |
|   ||
| BOOL | [hidesTransitionView](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a00b1533f15dc4ab6ce634549ffee76b4) |
|   | Flag to hide or show the transition view when in VR mode. [More...](https://developers.google.com/vr/ios/reference/interface_g_v_r_cardboard_view#a00b1533f15dc4ab6ce634549ffee76b4) |
|   ||

## 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: <https://www.google.com/get/cardboard/viewerprofilegenerator/>

## Property Detail

|---|---|
| |---| | - (id\<[GVRCardboardViewDelegate](https://developers.google.com/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p)\>) delegate | | readwritenonatomicweak |

Delegate to be notified of cardboard view rendering.

|---|---|
| |---| | - (EAGLContext\*) context | | readwritenonatomicassign |

The OpenGL context used for rendering.

Defaults to OpenGL ES3 context, if not set.

|---|---|
| |---| | - (BOOL) vrModeEnabled | | readwritenonatomicassign |

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 | | readwritenonatomicassign |

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