如何在横向模式下拍摄MKMapView快照

时间:2018-05-30 10:42:37

标签: ios swift mapkit mkmapview mkmapviewdelegate

我可以在纵向模式下拍摄Parameters: {"email"=>"user@example.com", "password"=>"[FILTERED]", "is_admin"=>true, "is_agent"=>true, "user"=>{"email"=>"user@example.com", "is_admin"=>true, "is_agent"=>true}} (0.2ms) BEGIN ↳ app/controllers/users_controller.rb:20 (0.2ms) ROLLBACK ↳ app/controllers/users_controller.rb:20 Completed 422 Unprocessable Entity in 17ms (Views: 0.2ms | ActiveRecord: 6.2ms) 快照,但不能在横向模式下拍摄。我使用下面给出的函数自动将MKMapView旋转到横向。我可以看到地图视图旋转到横向。但是,当我使用UIView拍摄快照时,我会再次以纵向模式拍摄地图。

MKMapSnapshotter

我的预感是将override var shouldAutorotate: Bool { return true } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { return .landscapeLeft } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .landscapeLeft } 设置为横向,但我不知道如何做到这一点。

MKMapSnapshotOptions

我希望上面的代码应该处理它,因为map-view已经旋转到横向,但事实并非如此。

let mapSnapshotOptions = MKMapSnapshotOptions()
mapSnapshotOptions.region = mapView.region
mapSnapshotOptions.scale = UIScreen.main.scale
mapSnapshotOptions.size = mapView.frame.size 

我观察到两种情况下mapView帧的相同值:纵向和横向。

我尝试使用mapView.frame.size = (375.0, 647.0) 。但没有收获。当已经设置了快照选项时,将调用以下函数。

CLLocationManagerDelegate

请建议还可以做些什么?

0 个答案:

没有答案