xcode 9 beta版本新建项目Argumented Reality App ,可以生成一个简单的AR Demo创建一个ARSCNView,这个类里面包含一个ARSession,ARSession的启动需要一个配置类,
关系如下图所示:
![](https://i-blog.csdnimg.cn/blog_migrate/ae5c62cc76011935349486df40f56fbe.png)
@property (nonatomic, strong) IBOutlet ARSCNView *sceneView;
- (void)viewDidLoad {
[super viewDidLoad];
// Set the view's delegate
self.sceneView.delegate = self;
// Show statistics such as fps and timing information
self.sceneView.showsStatistics = YES;
// Create a new scene
SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/ship.scn"];
// Set the scene to the view
self.sceneView.scene = scene;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Create a session configuration
ARWorldTrackingSessionConfiguration *configuration = [ARWorldTrackingSessionConfiguration new];
// Run the view's session
[self.sceneView.session runWithConfiguration:configuration];
}