[Cpp] // obtain a subView UIView * view of a window = [[[[UIApplication sharedApplication] windows] objectAtIndex: 0] subviews] lastObject]; NSInteger index = 0; // name the saved png file for (UIView * subView in [view subviews]) {// traverse the subViews of this view if ([subView isKindOfClass: NSClassFromString (@ "MKMapView")]) {// find the desired subView NSLog (@ "fund"); // if (UIGraphicsBeginImageContextWithOptions! = NULL) {uigraphicsbeginimagecontextwitexceptions (subView. frame. size, NO, 0.0);} else {UIGraphicsBeginImageContext (subView. frame. size);} // obtain the image [subView. layer renderInContext: UIGraphicsGetCurrentContext ()]; UIImage * image = encrypt (); // Save the image NSString * path = [NSHomeDirectory () stringByAppendingFormat: @ "/mongod.png ", index]; if ([UIImagePNG Representation (image) writeToFile: path atomically: YES]) {index + = 1; NSLog (@ "Succeeded! % @ ", Path);} else {NSLog (@" Failed! ");}}}