I am creating an app in which I have to show the registered users on the map. I have to display their profile pictures. There can be many of them, may be 1000, 2000, or 3000.
The problem is, by adding every image, its memory usage increases and the app slows down. For example, I am using just this piece of code:
UIImageView * imgView = imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"like_r.png"]];
for(int i=0;i<1000;i++)
{
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(31.4514885, 74.2642593);
marker.iconView = imgView;
marker.map=_mapView;
}
Is there a good way to show all users on the map?
Try setting marker.tracksViewChanges = NO;
to allow the CPU to idle.
Alternatively, set marker.image = [UIImage imageNamed:@"like_r.png"];
instead of setting the iconView, which should have a similar effect.
These changes should help with CPU, but may not solve the memory-related issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With