Does hiding "Legal" in MKMapView result in an App Store rejection? - ios

I'm displaying an MKMapView in a somewhat small square. It's small enough that the "Legal" text pretty much blocks half the map, so I'd like to get rid of it.
Is this allowed:
for (UIView *view in mapView.subviews) {
if ([NSStringFromClass([view class]) isEqualToString:#"MKAttributionLabel"]) {
view.hidden = YES;
break;
}
}
Not sure if I am risking App Store rejection by hiding it or using this method?

Yes, it will probably get rejected. Either because having the link is a legal requirement, or it'll be detected that you're using a private class (MKAttributionLabel).
That being said, you might get away with it for a few releases, if they don't notice.
Have you thought about using a static image instead of an MKMapView?

You are using undocumented features/classes. Since your map feature is very limited, you are better off using google's static map api instead of linking to a full feature framework just to show a small square of a map.

Related

Change UIAlertView with swizzling

I've recently been handed a private hardware SDK to integrate into my company's mobile app. Everything works great except they are using a UIAlertView as the result of some opaque method call, and my design team wants to brand this. I don't have access to the SDK's source code. Is there a way I can safely swizzle UIAlertView to preserve all functionality and simply modify the appearance of the UIAlertView so it's more branded/consistent with the app appearance? If so, would I overload drawRect or something else, and how would I figure out what the names of the labels in UIAlertView are so that I can draw them with the size, shape, and color that I want?
for added detail, the app does not currently use UIAlertView or UIAlertViewController so in theory swizzling would only affect whatever is going on with this closed-source SDK.
That wouldn't be straightforward at all.
If the SDK is using UIAlertView, then try swizzling the show method.
Your implementation should do approximately the following:
1) Do not let the original UIAlertView to show -- it is very hard to customize it.
2) Keep reference of old .delegate to be able to notify it when needed.
3) Create your own custom UIView and use [[UIApplication sharedApplication].keyWindow addSubview:myCustomAlertView];.
4) I believe you can get all of the previous UIAlertView variables (i.e. button titles, textFields, etc), using its properties such as
#property(nonatomic,copy) NSString *title;
#property(nullable,nonatomic,copy) NSString *message;
- (nullable NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
#property(nonatomic,readonly) NSInteger numberOfButtons;
#property(nonatomic) NSInteger cancelButtonIndex;
5) Create your own designs and call corresponding delegate methods when needed.
Other approach is to use Apple's Private API, but this may lead to bad results.
This is a VERY HACKY approach. Firstly, you have no guarantees that it would even work. Secondly, your app may be rejected. Therefore, I wouldn't really recommend it...
However, if you really want to go with this approach, then try doing this:
After [myAlertView show]; look at its properties after some delay (i.e. 0.01 sec is enough):
Now look for suspicious properties (probably of UIView class), which might have UI-related information. For example, __representer looks quite interesting -- it has constraints, it has labelContainerView... Try playing with those properties.
In order to get that __representer, use KVC and KVO (i.e. start with id theAlertController = [myAlertView valueForKey:#"_alertController"];). Then dive deeper and deeper.
Hopefully, you would be able to find useful properties and would be able to change their values via KVC.

How to remove an arrow from Google Maps geolocation marker (iOS)?

How do you remove an arrow from Google Maps geolocation marker (iOS)?
This is an arrow I'm talking about
If you really want to remove that arrow everywhere in your app from Google Maps SDK, it might be easiest to modify asset in GoogleMaps.framework.
Just navigate (cd) to GoogleMaps.framework/Versions/A/Resources/GoogleMaps.bundle/GMSCoreResources.bundle/ and notice the following files:
GMSSprites-0-1x.png
GMSSprites-0-2x.png
GMSSprites-0-3x.png
If you open these files, you can notice the arrow is there. So just edit directly in the asset by replacing arrow by nothing (transparent pixels).
Note: I haven't test it myself and this is not tested solution, but I believe it should work.
Disclaimer: I'm not sure, but I think this modification might violate Terms & Conditions for using the SDK. I don't get any responsibility for such modification, it's your call...
There is no way to do this with current version of the SDK (1.9.1), and actually there is an open issue with this request: Look here.
As a work around, you can hide the default button with:
_map.myLocationEnabled = NO;
Then create a custom GMSMarker
GMSMarker *pointMarker = [GMSMarker markerWithPosition:currentPosition];
pointMarker.icon = [UIImage imageNamed:#"YourImage"];
pointMarker.map = _map;
And change the position of it using a CLLocationManager, so it always show the current position. It's a bit tricky but is the only way, I could think, that you can achieve this. If you need a more complete example let me know.

Customize user location tint on iOS

I'm trying to change the color of the user location, as it is done in the "find my friends" app by Apple (see attached screenshot).
Note that I'm using the MapBox SDK, and I currently have the following method:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
}
I also looked into this thread to have an idea about how I should do something similar, but didn't find the same code for user location. Did Apple use a static PNG picture for Find my friends? Will I lose the adaptive circle around the position by changing it to another color (if that's even possible)?
UPDATE
As #Incanus said in his reply, in my -[RMMapViewDelegate mapView:layerForAnnotation:] callback method, I should get three calls corresponding to isUserLocationAnnotation = YES -- the dot, the accuracy circle, and the pulsing halo.
I only get one, and I don't get why.
Also, I tried to customise the annotation when the tracking mode changes, here's what I did:
if (self.mMapView.userTrackingMode == RMUserTrackingModeNone)
{
for (RMAnnotation *annotation in self.mMapView.annotations) {
if (annotation.isUserLocationAnnotation) {
if ([annotation.annotationType isEqualToString:#"RMAccuracyCircleAnnotation"]) {
[(RMCircle*)annotation.layer setFillColor:[[UIColor redColor] colorWithAlphaComponent:0.6]];
[(RMCircle*)annotation.layer removeAllAnimations];
}
}
}
[self enableBouncingOnLayer:self.mMapView.userLocation.layer];
}
else
{
[self.mMapView.userLocation.layer removeAnimationForKey:#"animateScale"];
}
So far so good, I get the blue accuracy circle to turn red and stop changing size.
The problem is, the MapBox framework will still update it, so it will go back to normal.
What's interesting is, using this method, I do have 3 annotation with isUserLocationAnnotation set to YES, but I only get one callback.
Any help appreciated.
In Swift 3,
mapView.tintColor = .red
Wonderfully straight forward now.
For the MapBox SDK, you can access the actual blue dot inside of the resources bundle and create a tinted version, either on the fly with Core Graphics or ahead of time as another resource in your bundle.
In Find My Friends, the dot is still blue -- they are actually just using an altered copy for other annotations. You can do the same.
You might also be interested in https://github.com/0xced/UIKit-Artwork-Extractor specifically for pulling resources out of the Find My Friends app, which is actually what we used on the MapKit framework to get the blue dot for the MapBox SDK ;-)
As Incanus pointed it out, I'm using the layerForAnnotation: method to customize my user annotation.
I then created this method to force an update of the layer, so that it can be drawn again.
- (void)refreshUserAnnotation {
[mUserAnnotation setLayer: [self mapView:mMapView layerForAnnotation:mUserAnnotation]];
}

Custom UISwitch bouncing when state changes from on/off - IOS-7 Bug?

I really need some help, since iOS 7 I have had nothing but trouble with UISwitch.
The Problem
After moving the view up when the keyboard is displayed and restoring it to original position, I then turn any UISwitch on/off it will work OK, however it will "Bounce Down" during the animation. this only seems to happen to UISwitch's that have the .thumbTintColor attribute. by that I mean self.borders.thumbTintColor = [UIColor redColor]; when the switch is off and self.borders.thumbTintColor = [UIColor greenColor]; when switch is on.
For clarity everything works well until the moving of the view (I can't not do this as you are not able to see the text field).
I have searched everywhere (including the class reference) and I haven't found anything helpful, or anyone else with this problem.
UPDATE
I have tried setting the UISwitch thumTintColor various ways, everything works fine until I move the view up to compensate for the Keyboard. if I drag the switch either on my iPad or via simulator on and off slowly the "bounce down" occurs halfway and when the color changes from green to red or red to green depending on state, I think this is an actual IOS7 UISwitch Bug. I really do not want to use a third part switch plug in on my app, so not sure what to do now, one would of thought that changing the tint color on the thumb would not have been such a huge problem.
I have tried turning off the animation from on to off - off to on makes no difference.
I have created a new UISwitch via code not IB and the same problem exists.
created a new test app with only a switch and text box to test and the same thing occurs.
Questions
1) My thoughts are this is a genuine bug. How do i log it with apple (never done it before) so if someone can point me to the correct place i would be grateful.
2) I am now thinking of using Buttons as switches, but feel that is not the way to go, are there any practical reasons not to do so i.e problems submitting the app to the App store etc?
I had the similar issue and found a solution. It's a bit hacky but it does the job.
Just need to add a small delay between setting isOn property to On/Off and changing the color of the thumb.
switch.isOn = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.switch.thumbTintColor = .white
}
Answer 1: Logging a bug with apple can be done via the iOS Dev center (There's a link on the bottom of the page). You can also ask for technical support. Click on the "Developer Support Center" button, then go to "Technical Support (TSI)" (Please note you only have a limited amount that you're allowed to use per year, before you have to buy more).
Answer 2: I think that having two buttons would be a very bad User Interface decision. Apple may reject it because of that (but you never know). I would get the bug report in, and go from there.
Good Luck!
I found interesting solution may be it helps.
NSArray *array = [self.mySwitch subviewsWithClass:[UIImageView class]];
for (UIImageView *imageView in array) {
imageView.image = [UIImage imageNamed:#"Untitled-1.png"];
}
Hear I used method from UIView category
- (NSArray*)subviewsWithClass:(Class)class
{
NSMutableArray *array = [NSMutableArray array];
if ([self isKindOfClass:class]) {
[array addObject:self];
}
for (UIView *subview in self.subviews) {
[array addObjectsFromArray:[subview subviewsWithClass:class]];
}
return array;
}
Image size is {57, 43.5}. Circle radius is 15(with shadow)
I understand that it is not very good way to solve. But if you really need it helps.
Play with images little bit =)

Best practices for managing facebook friends pics in iOS App

i'm working on an iOS app which has a tableview containing facebook friends' list, I want to manage this list for scrolling performance.
i don't want to load the images each time user open that friend list view, and for that images can be saved locally but at the same time it would not be a good practice as users can change their profile pictures after we already saved older ones to file system.
So i just wondering what is the best way to manage this?
Also how can i get those images in best possible optimized size?
thanks in advance
You might be able to use setImageWithURL:placeholderImage: in the UIImageView class in AFNetworking to load a placeholder (or existing image) and then request the latest image which will get updated when fetched.
The docs are here:
http://afnetworking.org/Documentation/Categories/UIImageView+AFNetworking.html
The project is here:
https://github.com/AFNetworking/AFNetworking/
UIImageView should take care of resizing the images.
Well if you want to set placeholder image it is possible. The FBProfilePictureView is a UIView but if take a look into the code you'll see that they add UIImageView to it. That's why you can use:
for (UIView *view in cell.faceImageView.subviews) {
if ([view isKindOfClass:[UIImageView class]]) {
[(UIImageView*)view setImage:[UIImage imageNamed:#"placeholder"]];
break;
}
}
Ofc, that's a workaround. However until they provide better thing you don't have to mess here with AFNetworking(which is a great lib btw) and finding facebook image url ;).

Resources