How to create UIButton that looks like UITableViewCell with AccessoryIndicator

Sometimes you need to create only one button, that looks like a UITableViewCell with accessory indicator. Users are familiar with this control and they know that if they click it, something should appear. For example, it can be used in different forms to select something after user taps a button. Using a UITableView with one section and cell is too complex approach if you need only one such button. Even if you need some more such buttons, you can use this solution to make code a little simpler.

I created an instance of UIButton and reached this goal after some search in StackOverflow and my own attempts. Finally, my button looks like this:

Yes, it is a UIButton, not UITableViewCell. So, how I did it?

You can look at my repository on GitHub, I have published a source code of such button under MIT Licence Terms.

Using Yandex Maps API & Core Location In iOS To Determine City Of a User By Reverse Geocoding

My goal was to determine the city or town name of a user to fill a region text field automatically in iOS app. At first I tried to use Core Location and MapKit, but I got only city names in English, for example, ‘Ufa’.  I had to get city names in Russian, so I decided to use Yandex Maps API. This is a final result – interface with a button to get city name automatically in Russian and a textField with a city name:

First, we add CLLocationManagerDelegate interface and an instance variable of CLLocationManager to get coordinates to our View Controller:

I created in my ViewController two helper methods to show and hide spinner without writing implementation of it:

I have a button on my ViewController. When it’s clicked a TextField is filled by a city name automatically after it is determined.

Here we tell, that our ViewController is a delegate of CLLocationManager.

This is a delegate method, that does all the remaining work. It is called after coordinates are determined. I used SBJson framework to parse JSON.

This is an error handling for Core Location:

This method shows an error if we failed to determine city automatically:

The same goal can be achieved using MapKit instead of Yandex Maps API for English city names:

Finally, some test locations. Replace the appropriate string to simulate another coordinates. This could be done in Simulator settings also in Debug/Geo section.