Following document is dedicated for the following: LifeCycle Management of MAXST AR and Start/Stop of Camera & IMU Sensor for iOS Device
LifeCycle Management of MAXST AR
Operate tracker from the selected tutorial after combining MaxstAR to LifeCycle of the ViewController that you wish to operate.
※ Correct license key must be entered to MasMaxstAR.setLicenseKey() function to properly activate.
Refer to API Reference for each functions' guideline.
※ When the incorrect license key is entered, Invalid Signature will appear as watermark, and target tracking and AR contents rendering will fail to operate.
override func viewDidLoad() {
MasMaxstAR.setLicenseKey( "your license key");
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
MasMaxstAR.setScreenOrientation(orientation);
MasMaxstAR.onSurfaceChanged(width, height);
}
override func viewDidDisappear(_ animated: Bool) {
MasMaxstAR.deinit()
}
Start/Stop Camera
In order to start/stop camera from ViewController, register observer regarding didBecomeActiveNotification, didEnterBackgroundNotification, willResignActiveNotification, call upon functions of Start/Stop Camera that match each event.
override func viewDidLoad() {
NotificationCenter.default.addObserver(self, selector: #selector(pauseAR), name: UIApplication.willResignActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(enterBackgournd), name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(resumeAR), name: UIApplication.didBecomeActiveNotification, object: nil)
}
Start/Stop Camera from ViewController
@objc func resumeAR() {
cameraResultCode = cameraDevice.start(0, width: 1280, height: 720)
}
@objc func pauseAR() {
cameraDevice.stop()
}
@objc func enterBackgournd() {
cameraDevice.stop()
}
Start/Stop Sensor
Start/Stop IMU Sensor from ViewController
※In case of Instant Tracker, IMU Sensor data is required.
@objc func resumeAR() {
sensorResultCode = cameraDevice.start(0, width: 1280, height: 720)
}
@objc func pauseAR() {
sensorDevice.stop()
}
@objc func enterBackgournd() {
sensorDevice.stop()
}
