How To Use Xcode’s Auto Layout To Center Elements In An iOS App

Centering elements in Interface Builder is very simple, because Xcode will snap items to the vertical or horizontal center of the canvas, the same way that other Apple apps help you center items in a document (Pages and Keynote are the first examples that came to my mind).

However, when it comes to iOS apps, just because an element looks centered in the canvas, doesn’t mean that it will be centered all the time on every device: if you switch to a device with a different screen size (even in the simulator), the elements won’t be centered anymore.

This is because, in Interface Builder, you place elements with fixed positioning by default. If you want your app to look the same on every screen size, you will have to use a technique called Auto Layout.

Continue reading

How To Add A Launch Screen To An iOS App

I have recently started to play around with Swift programming as I always wanted to code something for iOS, but always ended up either lacking the time to do it, or developing for Android, a platform with which I am more experienced since my university days.

One of the most confusing things for me, coming from Android development and its interfaces in plain XML, was getting used to Interface Builder in Xcode, finding the elements I need, ultimately, getting the storyboard files to do what I want them to do. Also, navigating the Xcode project settings is no easy task for a beginner, so I am still finding roadblocks every time I try to do the most simple tasks.

Continue reading

Use The Google Play Services Location APIs In Your Android Apps

Today, while troubleshooting an issue with the GPS location in an Android app I am working on as a side project, I stumbled upon this question on Stackoverflow and, reading the answers, I was brought to a page on the Google Developers website titled Making Your App Location-Aware.

An interesting extract from that page is this:

The Google Play services location APIs are preferred over the Android framework location APIs (android.location) as a way of adding location awareness to your app. If you are currently using the Android framework location APIs, you are strongly encouraged to switch to the Google Play services location APIs as soon as possible.

Well I guess you never stop learning. I had no idea about this and, looking at my Android project, I see that I have always used android.location rather than the Google Play Services location APIs.

I guess it’s time to at least try the Google APIs then, although I am not sure why it is recommended over Android’s own location API, but there must be a reason why we are strongly encouraged to switch.

How To Pass Information From a Fragment To an Activity In Android

After my previous introductory post on Android fragments, the next natural step in the series would be to explain how to send information from a fragment to an activity.

This is not going to be a step-by-step tutorial like the previous one (it would be pointless to cover the project creation once again) but I will include all the necessary code to make fragment-to-activity communication work.

Continue reading

Android Fragments – An Introductory Tutorial

Fragments are a way to make your Android application modular and more flexible. This is a short and, hopefully clear, introductory tutorial on how to implement fragment functionality in your Android application.

Continue reading

How To Get Latitude And Longitude From City Name In PHP

This is a quick and easy way to find out latitude and longitude information of a specific city in PHP, using the Google Maps API.

Continue reading

Using the CSS text-transform Property Is Good

We should always try sticking to the three-layer model of web development:

  • The structure and content layer: HTML
  • The presentation and design: CSS
  • The behavior: Javascript

This makes for easily maintainable web pages, better performance thanks to caching and increased re-usability since you have everything in a specific file and this makes it easy to move it somewhere else.

Continue reading

How To Look For Multiple Words With jQuery’s :contains Operator

I love jQuery. Well, love is a big word actually, let’s say that I like it much more than plain Javascript. It allows me to code quicker, at a higher level and, most importantly, to focus on what I want to do more than on how I have to do it.

Having said this, I don’t use Javascript/jQuery as often as other programming languages, so I am not as fluent as with PHP for example, and sometimes I find myself having to go back to the basics. I have recently had to find a way to use the :contains operator to look for multiple words inside <div> elements on a webpage, but the jQuery documentation doesn’t include any examples for these scenarios. Luckily, jQuery allows you to do this very quickly. Here’s how.

Continue reading

© 2018 Daniel's TechBlog

Theme by Anders NorénUp ↑

%d bloggers like this: