GMSPanoramaView转换为图像



如何将街景(GMSPanoramaView)转换为图片?我对普通地图视图没有任何问题。这是我用于地图的代码:

UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
SaveMapForSyllabus *SMFSVC = [segue destinationViewController];
SMFSVC.image = mapImage;

制作图像后,我将其传递给保存图像的另一个视图控制器。此外,它正在保存一些图像,但它只是带有谷歌徽标等的灰色/黑色视图,如标准地图/街景所示。它迷失在某个地方的全景。

我遇到了同样的问题。 我不知道如何将其转换为图像,因此最终我想出了一个移位解决方案。 我希望能够在UITAbleView单元格中将这些视图显示为缩略图。

问题是您无法将GMSPanoramaView分配给cell.imageview.image属性。 虽然这可能不会直接回答您的问题,但此解决方案是一种可行的解决方法,我希望它对您有所帮助。 我只是决定将UITableViewcell的图像与GMSPanoramaView叠加,将其约束和框架设置为相同,并将其作为子视图添加到单元格中。 这是我的代码。 这一切都发生在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath委托方法中:

cell.imageView.image = [UIImage imageNamed:@"NoImageAvailable"];
// Is this an actual UIImage or not?  If not, in my case it is a GMSPanoramaView
if ([[tableItem mapImage] isKindOfClass:[UIImage class]]) {
}else{
    // this will overlay over the no image available because we need
    // the image to stay there to enforce constraints since this view
    // isn't a true image and is just overlaying the cell image
    CGRect frame = cell.imageView.frame;
    UIView *viewToAdd =(UIView*)[tableItem mapImage];
    viewToAdd.frame = frame;
    NSArray* contraints = cell.imageView.constraints;
    [viewToAdd addConstraints:contraints];
    [cell addSubview:viewToAdd];
}

最新更新