How do I animate MKAnnotationView drop?

One problem with the code above by Anna Karenina is that it doesn’t deal with when you add annotations below where the user is looking at the moment. Those annotations will float in mid-air before dropping because they are moved into the user’s visible map rect. Another is that it also drops the user location … Read more

Changing the UIBackButtonItem title

I’ve had success by creating my own UIBarButtonItem instead of setting the title of the existing one: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@”Back” style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = backButton; [backButton release];

iPhone remove substring from string

NSString *str=@”1,2,3,4″; [str stringByReplacingOccurrencesOfString:@”3,” withString:@””]; That will remove ALL occurrences of @”3,” in str. If you want to remove only the first occurrence of @”3,”: NSString* str = @”1,2,3,4″; NSRange replaceRange = [str rangeOfString:@”3,”]; if (replaceRange.location != NSNotFound){ NSString* result = [str stringByReplacingCharactersInRange:replaceRange withString:@””]; } Hope this helps.

Get the domain part of an URL string?

Objective-C NSString* urlString = @”http://someurl.com/something”; NSURL* url = [NSURL URLWithString:urlString]; NSString* domain = [url host]; Swift 2 var urlString = “http://someurl.com/something” var url = NSURL(string: urlString) var domain = url?.host Swift 3+ var urlString = “http://someurl.com/something” var url = URL(string: urlString) var domain = url?.host

Is there any technical/conceptual reason why iOS does not support Cocoa Bindings? [closed]

Bindings on the desktop requires: All suitable UI components to expose bindings for their important properties Implementation of NSArrayController infrastructure for handling selection On iOS, point 2 becomes less of an issue. It is rare (and perhaps even a bad UI design) to have a master-detail view layout where multiple selection is possible. This is … Read more

How to create backBarButtomItem with custom view for a UINavigationController

As of iOS5 we have an excellent new way of customizing the appearance of almost any control using the UIAppearance protocol, i.e. [UIBarButtonItem appearance]. The appearance proxy allows you to create application wide changes to the look of controls. Below is an example of a custom back button created with the appearance proxy. Use the … Read more

How do I get a list of countries in Swift ios?

You can get a list of countries using the NSLocale class’s isoCountryCodes which returns an array of [String]. From there, you get the country name by using NSLocale‘s displayName(forKey:) method. It looks like this: var countries: [String] = [] for code in NSLocale.isoCountryCodes { let id = NSLocale.localeIdentifier(fromComponents: [NSLocale.Key.countryCode.rawValue: code]) let name = NSLocale(localeIdentifier: “en_UK”).displayName(forKey: … Read more

tech