Implementing Pull-to-Refresh and Handling Empty Table14 July 2014
In this iOS Programming 101 post, I would like to answer two common questions raised by our readers.
- I follow your table view tutorial to create my first app. The tutorial is great. It shows us how to display data in the table view. But what if the table is empty? When there is no data, the app should display a friendly message instead of just display empty rows. How can I do that?
- I like the pull-to-refresh gesture. It’s a great way for content update. How can I implement such feature in my table-based app?
Let us first take a look at the first question and see how to display a text message when the table is empty. The UITableView class includes the backgroundView property, which is the background view of the table view. This property is set to nil by default. To display a message or an image when the table is empty, usually we configure this property and set it to our own view.
How to Use SQLite to Manage Data in iOS Apps
Among the numerous applications existing on the App Store today, it would be hard for someone to find more than a few of them that do not deal with data. Most of the apps handle some sort of data, no matter in what format they are, and always perform some actions upon it. There are various solutions offered to developers for storing and managing data, and usually each one of them is suitable for different kind of applications. However, when working with large amount of data, the preferred method it seems like a one-way path: That is the use of a database.
Indeed, making use of a database can solve various kind of problems that should be solved programmatically in other cases. For programmers who love working with databases and SQL, this is the favorite data-managing method at 90% of the cases, and the first think that crosses their minds when talking about data. Also, if you were used to working with other databases or database management systems (DBMSs), then you’ll really appreciate the fact that you can keep applying your SQL knowledge in the iOS platform as well.
The database that can be used by apps in iOS (and also used by iOS) is called SQLite, and it’s arelational database. It is contained in a C-library that is embedded to the app that is about to use it. Note that it does not consist of a separate service or daemon running on the background and attached to the app. On the contrary, the app runs it as an integral part of it. Nowadays, SQLite lives its third version, so it’s also commonly referred as SQLite 3.
A Beginner’s Guide to Optionals in Swift
Swift was announced three weeks ago. Since then, I have been reading the Swift’s official guide and playing around with it in Xcode 6 beta. I started to love the simplicity and syntax of Swift. Along with my team, I am still studying the new language and see how it compares with Objective-C, a 30-year-old programming language. At the same time, we’re working really hard to see how we can teach beginner and help the community to pick up Swift effortlessly.
Two weeks ago, we covered the basics of Swift. In coming weeks, we’ll write a series of tutorials to cover a number of new features in Swift. This week, let’s first take a look at optionals.
Using iAd to Display Banner Ad in Your App
So, you are about to start developing the next super app, you have everything planned and designed, but there’s still one last thing you haven’t made your mind up about; how to make some earnings out of it! Well, there are two options apart from offering it completely free: Either to make it a paid app where your potentials users should pay to download it, or make it a free app, add some advertisements, and earn a revenue from the ads.
Today’s trends show that it’s more possible for users to download free apps, instead of paid ones. They will pay for an app if it really worths it, or if it’s super famous and have received good rating. So, having that in mind, you decide to make your app a free one, and integrate advertisements in it. To do so, you have various services to pick from in order to display ads, and one of them is the iAd Network provided by Apple. Undoubtably, you have already concluded even from the tutorial’s title that the today’s topic is about how to use iAd advertisements, but before we see all in action let’s see some introductory stuff.
Deciding about the kind of your application (paid or free) before starting the actual implementation is really important, as it affects your work directly. For paid apps, there’s no need to do anything particular, however for free apps it’s necessary to define where the ads will appear, and setup your interface accordingly. Speaking of position, ads should be placed either to the top or the bottom of your view controller. If your app does not contain a tab bar, then ads should be placed at the bottom of the screen, otherwise at the top. Note that if you display ads anywhere else in the view, then the Human Interface Guidelines are breached and Apple will reject it with no second thought.
Getting Started with Swift: A Brief Intro of the New Programming Language
If you’ve watched the WWDC keynote, you should be amazed by an innovative feature calledPlaygrounds that allow you to experiment Swift and see the result in real-time. In other words, you no longer need to compile and run your app in the Simulator. As you type the code in Playgrounds, you’ll see the actual result immediately without the overheads of compilation.
At the time of this writing, Swift has only been announced for a week. Like many of you, I’m new to Swift. I have downloaded Apple’s free Swift book and played around with Swift a bit. Swift is a neat language and will definitely make developing iOS apps more attractive. In this post, I’ll share what I’ve learnt so far and the basics of Swift.
First Time App Developer Success Stories Part 3: Am I Too Late to Learn iOS Programming
Am I too late to start learning iOS programming? Simply do a search on Google or Quora. You’ll see lots of discussions around the web. The mobile market has created tons of opportunities and possibilities. It’s amazing you can turn an idea into app that millions of people use. I’ve met a lot of people who love to create apps but think coding is difficult and it’s too late for them to learn to code.
It’s never to late. It’s the lack of determination and drive that keep you from learning programming. Some time ago, we shared the first and second parts of app developer stories. In part 3 of the series, we featured even more app developers to share their success stories. The ages of these first-time app developers range from 15 to 68 years old. Yes, you read it right. Robert Chalmers, one of the featured developers, is 68 years old! Though Robert got years of experience, it’s amazing he still keeps learning new programming language. I couldn’t imagine if I would still learn programming at that age. Rémy Spehler, who is a doctor by profession, started from zero programming experience to published his first app at the age of 58. The design of their apps is elementary and may not catch your attention. But they set a great example showing that everyone can learn iOS programming and build apps regardless of age.
I haven’t highlighted all the developers here but all of the stories are truly inspiring. Read on and check out their success stories.
Integrating Facebook Login in iOS App – The Manual Way
In my previous tutorial, I presented an easy and fast way to implement the login with Facebook feature. Based on the FBLoginView class, I demonstrated how logging in and out from Facebook can be done in really a few minutes with the assistance of a predefined login button. In this tutorial we’ll do the exact same thing, but this time we won’t use any automatic solution. Instead, we will implement every part of the login process manually and we’ll see in some detail level how everything works when connecting to Facebook. That’s a useful knowledge to have, as there are many cases that the default login view we saw in the last tutorial isn’t handful at all.
Before we start programming, it is necessary to present some basic terms, so you’ve got an idea about the whole process. The first important thing you should know, is that after a successful login with Facebook the app receives an access token. This is a unique key, that allows to perform requests and exchange data with Facebook in a secure fashion, without having to authorize the app all the time. One could say that the whole login hassle happens just to get that access token. Once received, and depending on the permissions your app asks for, you can freely get and send data.
How to Integrate Facebook Login in iOS App
Integrating Facebook features into an app is nowadays a quite common task, and one of the most important steps in the integration process is the login functionality implementation. Logging in with Facebook not only allows you to attach a social characteristic into your app, but it can also be used as a login system instead of creating a custom one. By adding it you offer to users a familiar way to authenticate, considering that the majority of users use Facebook.
Facebook integration is natively supported since iOS 6, even though it’s still necessary to manually add the Facebook SDK into your projects. There are two ways provided by the SDK for logging in with Facebook. The first one consists of a relatively easy solution, as it uses a predefined login view which manages all the session and login related stuff. The second one is a more “heavy” approach as everything must be implemented and handled by the developer, but on the other hand the login process can be highly customized. The method that should be used into a project definitely depends on the app’s requirements. If the predefined, familiar Login with Facebook button fits to the application’s look and feel, then this should be the number #1 option. If further customization is needed, then the programmatic option is a one-way road.
In this tutorial we are going to see how to login with Facebook using the first way, so let’s talk a bit more about it. The login view, or programmatically speaking the FBLoginView class, provides a standard Facebook button to log in and log out from the app. The appearing position of the view can be specified, but neither its size or its title can be changed. Actually, the title is automatically set according to the logged in status at a given time. Behind the scenes, the class is responsible to carry out all the heavy work. It manages all the communication with Facebook, it handles the various session changes, it persistently stores the authentication token received from Facebook after a successful login, it checks for an existing token upon the application launch, and a lot more. Developers don’t have to deal with all that details, or even care about them. They are only required to add the login view to the appropriate view controller, define all the desired permissions and implement a few delegate methods to handle the login state changes.
Introduction to UIActionSheet and UIPopoverController
All mobile applications, no matter what they are about, they have one common and obvious characteristic: They offer interaction, which means that they are not static, but require input or actions needed to be taken by users from time to time in order to function properly. One quite usual behavior, is the ability to provide ways that allow users to make choices or take decisions where it’s needed, and ultimately act that way on the applications’ data or functionalities. iOS SDK provides a pre-made action-taking view controller, the UIActionSheet.
Action sheets consist of a really convenient and fast way to display a bunch of options that the user should select from, and it is widely used in great number of applications. Its disadvantage though is that it adopts the iOS’s look and feel without being able to be graphically modified, therefore it might not fit to applications with customized GUI.
Beyond action sheets, another very important and cool tool designed especially for the iPad, is theUIPopoverController. A popover controller is actually a container which is used to display content on top of another content. What makes it unique is the fact that it can be displayed almost everywhere around the screen of the iPad, but usually it’s shown near to the button that caused its appearing with a nice arrow pointing to the button’s direction. iOS by default encloses action sheets in popover controllers on iPad, but they can also be manually created for custom content.
Before we begin working with those two view controllers, let’s do some more talking about them in order to get to know their basics, and then we’ll proceed on how to use them in projects. So, let me start by telling that both the UIActionSheet and UIPopoverController exist to serve the same purpose, and that is to provide a quick way for presenting content to the user. This content can be either a button-based menu (action sheet), or anything else originating from a view controller (popover controller). Undoubtably, they are both pretty useful tools, and everyone developing for iOS should master both of them. Their great difference lies to where each one is used, and that’s the essential fact you should be aware of: An action sheet can be used on any iOS device (iPhone, iPad), but a popover controller can be used only on iPad, as I have already said.
iOS Programming 101: How To Create Swipeable Table View Cell to Display More Options
When iOS 7 was first released, one of the many visual changes that particularly interested me was the swipe-to-delete gestures in the Mail app. By now you should be very familiar with the feature. After you swipe a table cell, you’ll see the Trash button, plus a new button named More. The More button will bring up an action sheet that shows a list of options such as Reply, Flag, etc.
I thought it’s a great feature to provide additional options for manipulating a table record. However, as you know, Apple didn’t make this feature available to developers in iOS 7. You can only create the swipe-to-delete option in table cell. The More feature is only limited to the stock Mail app. I have no idea why Apple keeps such great feature to its own app. Fortunately, some developers have created free solutions (such as UITableView-Swipe-for-Options, MCSwipeTableViewCell) and made them available freely.
In this tutorial, I’ll use SWTableViewCell and see how to implement swipe-to-show-options feature in your app. SWTableViewCell is pretty to easy to use. If you understand how to implement UITableView, you shouldn’t have any problem with SWTableViewCell. On top of that, it supports utility buttons on both swipe directions. You’ll understand what it means in a minute.
Let’s get started and build our demo app.
Comments closed on this post.
- image,photo,image picker,UICollectionViewCell
- Status Bar
- Text to Speech
- Objective C, Swift,UIPrintInteractionController
- swift tutorial,swift
- HTML, webview
- swift tutorial,swift
- Game, Swift
- UITableview Cell, Swift
- view controllers,detached
- Wifi file Transfer
- NSTimer, Swift
- swift tutorial,swift
- Storyboards, ios9
- Alert View
- navigation bar, Swift
- iOS, swift, platform, factors to consider
- webview,android, iOS,swift
- webview, android
- JSON, Swift
- Mobile App Development
- swift, tricks