Generating UIButton Programmatically

uibuttonWhen you are working on an iOS app, you invariably end up creating buttons on your view controllers. For some of the apps, you know exactly where everything goes and you place everything beforehand in your storyboard file. But if your app is more complex, you may want to create the buttons dynamically. This means is that creating a button might be interactive and can depend on the actions of the user. How do we create buttons programmatically? Once they are created, how do we associate actions with them?   Continue reading “Generating UIButton Programmatically”

How To Trigger A Segue Programmatically In iOS

mainYou have your storyboard ready and you have created the necessary segues. Great! Now how do we trigger these segues programmatically? There are many different ways to do it. One of the nicer ways to do this is by connecting two scenes in a storyboard using a segue that is not attached to an action. After that, you can programmatically trigger the segue inside your view controller. The way you do this is by control-dragging from the file owner icon at the bottom of the storyboard scene to the destination scene.   Continue reading “How To Trigger A Segue Programmatically In iOS”

Dismissing The UITextField Keyboard

ios-keyboardLet’s say you are designing an iOS application which takes user input using a text field. When you add a text field to your storyboard and run your application, you will see that when you tap on the text field, the keyboard pops up automatically. But when you tap the return key, they keyboard doesn’t go away. As it turns out, the popping up of the keyboard is taken care of when you add the UITextField, but dismissing the keyboard is up to you. Here’s how you make it go away after you are done taking the input from the user:   Continue reading “Dismissing The UITextField Keyboard”

iOS App: Separator Lines And Back Button In Master-Detail Application

mainWhen you create a master-detail application in iOS, a few things appear by default. If you notice it, you will see that the empty cells are separated by lines. But we want the separator lines to appear for items that are there in the table. Also, you will notice that the back button in the detail view contains the title by default. What if we want it to say something else? Perhaps not say anything at all. How do we do it?   Continue reading “iOS App: Separator Lines And Back Button In Master-Detail Application”

How To Load Different XIBs Based On The Device Type?

mainWhat’s with all the different sizes of the iOS devices? I mean, sure we have autolayout feature that takes care of things in general. But if you want real aesthetic perfection, then you are better off having a separate XIB for each screen size. If you create a universal app, Xcode automatically creates two separate XIBs for iPhone and iPad. But if you want to differentiate between the 3.5 inch screen and the 4 inch screen on the iPhone, you should create a new XIB and add it to your project. You should of course name them accordingly. You can then load the XIBs by checking for the device type as given below.   Continue reading “How To Load Different XIBs Based On The Device Type?”

Transition Effects In iOS Apps

One of the more visually appealing aspects of iOS development is the crisp transition effect. Whenever you see a beautiful iOS app, it has all the elements interacting with each other seamlessly with gorgeous transitions and other visually appealing effects. If you have tried your hand at building one of these apps, you must have noticed that there are a couple of default options available, like flip or curl. But how do we go past this? How do we build all the fancy transition effects into our app? There are actually two different approaches you can follow.   Continue reading “Transition Effects In iOS Apps”

Storyboards vs XIBs

mainThe concept of storyboarding was introduced by Apple in iOS 5. This was the first major deviation from using the interface builder to build iOS apps. Storyboards were created to help developers visualize the flow of the application. It is a lot like having a bunch of XIBs, but in a single file. You can also create custom transitions via code that will change dynamically if needed, much like you can with XIBs. But a lot of people who are new to iOS development get confused between XIBs and Storyboards. What should you use for your project? Does it matter one way or the other?   Continue reading “Storyboards vs XIBs”

How To Set The Background Image For Your iOS App?

When you are designing your iOS app, you cant help but think about the aesthetics. You want to present your app in the best possible way. There are some things you cant ignore, like the icon, or the background, or the first screen. These are the things that tend to impact your app the most. Although the functionality is the most important part, a new user will not get there if you don’t make your app look aesthetically pleasing. A new user doesn’t know what your app does, so you should give the user a strong reason to keep going. The background image is one of the key aspects in your app. There are two ways of setting the background image.   Continue reading “How To Set The Background Image For Your iOS App?”

How To Remove The Gloss From The iOS App Icon?

mainNot a big fan of the glossy effect on your iOS app icon? Well, let’s remove it then. The glossiness in the app icons epitomizes the skeuomorphic design that Apple embraced a few years ago. When it first came out, it was all new and exciting. Apple is now moving to a flat design with iOS 7, and besides, some icons just don’t look good with the gloss. As far as removing the glossiness is concerned, there are basically two ways to do this. Well, actually the same thing happens under the hood, one is basically a shortcut for the other. Let’s see how to to do it.   Continue reading “How To Remove The Gloss From The iOS App Icon?”

How To Convert iPhone XIB To iPad XIB?

So you started a universal iOS app and finished up everything on the iPhone XIB. Now it’s time to do the iPad XIB. But wait a minute, do we have to redo the whole thing? Isn’t it repetitive and tedious to all the mappings and connections all over again? The good thing is that there is a way around it. You only need to do minimal work to get your iPad XIB up and running on Xcode 4.   Continue reading “How To Convert iPhone XIB To iPad XIB?”