SwiftUI allows us to make static table views by using a List view. The SwiftUI syntax makes the process extremely simple. Unlike UITableViewControllers that require you to manually specify that you are using static cells, and then have to assign the table view controller a class, you simply just add “List { }” to your code and insert all of the views you want in-between the curly braces.
[Read more…]SwiftUI HStack, VStack, ZStack Tutorial
When you create a SwiftUI view, the protocol defines that we need to return “some View”. The word “some” means that we are dealing with an opaque result type. This is a new feature added added in Swift 5.1. An opaque result type means that we must return one, and only one, of the specified type, in this case something that conforms to the “View” protocol.
This highlights a problem. Imagine if our view, ie… the part that the user interacts with on screen, was only able to show one Text field or perhaps one button, then interfaces would be incredibly boring.
[Read more…]Getting a List of Messages with the Gmail API
After authenticating with Google using GoogleSignIn, one of the next steps I wanted to tackle in my app was retrieving a list of messages. Here is the reference on this part of the API. What we see is that it requires a userId (which is your email address… or alternatively just the value “me”).
It has some optional query parameters such as indicating if you want to also include trash and spam folders, as well as filtering on labels. You can also pass in a query string in exactly the same format as you would the Google Search Box on email. Such as “from:[email protected]”, or just by keyword or phrase, etc…
On the right of the page there is also a way to test this out. In userId put in your email address and in labelIds, put in the word INBOX in CAPS.
[Read more…]Implementing GoogleSignIn with Swift
I am currently in the process of building an email client app for iOS, and after that, the Mac. At the moment I am working on users being able to sign in to their Gmail account so that they can manage emails with within the app.
One of the first steps with working with the Gmail API is to be able to sign in. At the moment I have implemented GoogleSignIn which is one of a few ways that Google allows you to authenticate.
[Read more…]How to Display HTML in UITextView with Swift
I was working with the Google APIs Client Library for Objective-C for REST today and when working on retrieving email messages from Gmail I noticed that the Data being passed, once decoded from base64, contained HTML in some cases. In this quick tutorial I’ll provide a quick example of one way that you can display a string containing HTML and put it in a UITextView.
Instead of showing how to retrieve an email from Gmail, and then access the data string and go through the conversion to make it a readable string, I’ll just begin from a hard-coded HTML string and show how that can be used in a UITextView.
[Read more…]Connecting to the DJI/Ryze Tello SDK with iOS and Swift – Tutorial
I recently received a DJI/Ryze Tello as a gift from family. The Tello is a small drone weighing just 80g that works both indoors and outdoors (although you need good light and good conditions, ie, no wind, to be safe when using it outside). It has a downward facing vision system that allows it to stay steady when hovering. It works up to 100m away and is controlled by a smartphone or table via the Tello app.
The Tello has a 5mp camera on the front that streams 720p video to a phone or tablet. When you have a strong wifi signal, you can capture some fairly decent footage (not Spark, Air, or Mavic quality, mind you). There is no gimbal, although it does have electronic image stabilisation (EIS) which when the drone is in slow mode, it keeps the video level and fairly steady regardless of what direction you move the drone.
[Read more…]Passing Data Between View Controllers with Swift
When developing an app, you might come across a need to pass some data from one view controller to the next view controller.
To demonstrate this functionality, we will create a very simple contacts application. The main view will use a UITableView to show first and last names of each individual in the custom contacts list. When tapping a name, the app will segue to a second view to show the contacts phone number and other details.
There are many ways we can solve this problem, such as using notifications or delegates to pass information around, but in this example we will pass some information from one view controller to the next view controller so that the “next” view controller knows what information to store.
[Read more…]Using the CLCircularRegion to Setup a Geo Fence
We have previously looked at how to use region monitoring with iBeacons using a CLBeaconRegion. Today we’ll look at the CLCircularRegion for region monitoring. There are some similarities between the CLBeaconRegion and CLCircularRegion. Both inherit from CLRegion which means there are some aspects that they share. In our iBeacons tutorial we created region monitoring which looks out for bluetooth transmitters called iBeacons. When the app detects the iBeacon it triggers a delegate method to be called which allows you to inspect a major and minor value to know which region was triggered. You can program the app to detect when you come in to range, or when you leave range.
With the CLCircularRegion we use geo location instead of bluetooth signals. This allows us to create geo fences which are defined by a centre point on a map along with a radius. When the phone passes in or out of the CLCircularRegion, the appropriate delegate method is fired and your app can be programmed to act accordingly. Common uses include controlling a smart home and setting a geo fence which when you leave the fence, it switches off your heating. Popular todo task manager apps, such as OmniFocus, use geo fences to let you know when you enter a region on a map where you need to perform a task.
In todays tutorial we’ll look at how to create a CLCircularRegion and how to start monitoring for that region. [Read more…]
CMMotionManager Tutorial – Part 4 – Device Motion Data
In this tutorial we will look at Device Motion which provides various measurements from the sensors on the iPhone. The data is represented by the CMDeviceMotion class which encapsulates measurements taken by the onboard sensors.
Rather than providing raw values from the accelerometer, gyroscope, or magnetometer, the CMDeviceMotion class provides data that has been processed by “Core Motion’s sensor fusion algorithms”. The data is cleaned up, and has bias removed.
In todays tutorial we’re going to look at how to access CMDeviceMotion and create a simple needle that faces down regardless of the direction you rotate the phone around the Z axis. [Read more…]
- « Previous Page
- 1
- 2
- 3
- 4
- 5
- …
- 12
- Next Page »