Posts

Showing posts with the label Swift 5

RW.com: Navigation Tutorial - Part 1

Image
Alright! A new article - technically a tutorial to focus on. This one is all to do with navigation. Start Time - 14:20 Here is the link, from Audrey Tan: https://www.raywenderlich.com/5824937-swiftui-tutorial-navigation Before I start, just having look to see what's there. Good to see the ContentView empty at the moment - that's genuinely good to see we're adding from scratch! In the 'Artwork' file, we have a custom struct for Artwork, then an array full (17!) of different artwork values. Each has a whole list of properties. In the MapView file we have some code that I'm not familiar with. OK, let's go to the actual tutorial! SwiftUI Basics Yes I agree with Audrey - I MUCH prefer how the code directly matches to the view, so you can keep track of it all. Also, just the one main ContentView is easier than using storyboards. Another key point is that UIKit can still be used alongside UI. Declarative App Development So what does declarat...

RW.com: Animations Article - Part 1

Image
The run continues! Like I said, my plan is to absorb knowledge from these 'beginner' articles. I won't get ALL of it - there'll be stuff beyond me for sure. But there WILL be elements to glean from them, that's the point. In the past I've been too concerned with understanding every aspect but actually, it's more like gradually building a complex puzzle - one piece at a time! Start Time - 15:16 https://www.raywenderlich.com/5815412-getting-started-with-swiftui-animations *Article dated Dec 9th 2019 Again, this could well be over two parts. We'll see! The three key things we're going to learn are animation MODIFIERS and withAnimation - that's the function which lets you animate STATE CHANGES. And Custom Animations! Opened project - here are the various Swift files already put in! And here's what the view structure is - The app is to basically bring up info about the planets in the solar system. Basic Animations *subheading...

RW.com: Storyboards Segues Article - Consolidation

So, as mentioned, I need to consolidate this particular article. There was so much code there, I just wanted to look over it one more time and make sense of it all - from the Xcode project.  Start Time - 13:05 Let's look at one Swift File at a time. First of all the model - this is what was already created before the article: struct Player {   var name : String ?   var game : String ?   var rating : Int } A simple struct here. Name and game are optional because there may be no value (nil) put in - stops the program from crashing. Rating is an int - a score out of 5. That's interesting as anything could actually be set for it! The rating part wasn't actually covered in this project.  Now we have the view file: import UIKit class PlayerCell : UITableViewCell {      @IBOutlet weak var gameLabel : UILabel !   @IBOutlet weak var nameLabel : UILabel !   @IBOutlet weak var ratingIma...

RW.com: Storyboards Segues Article - Part 2

Image
Yes I'm back on the same day! One good thing about 'distancing' is having genuinely more time to code. Limiting in lots of other ways but every cloud and all that... So back on with the article - second and final part! Then a practical play around... Start Time - 13:20 Same article as before - https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more#toc-anchor-010 We're up to 'Selecting the Game' So for this, we have another 'unwind segue'. The exit bit now works after the game is selected, but nothing actually is selected. Here is what we're actually selecting. Right more fancy code added! Various bits about the GamePicker. Needing the identifier to match up to something or other. Again, I'm sure this is a lot easier in SwiftUI. This was specifically to get the checkmark in - if indexPath. row == gamesDataSource . selectedGameIndex {       cell. accessoryType = . checkmark     } else {       cell...

RW.com: Storyboards Article - Part 1

Image
So, the first time I'm learning via an article! There are plenty of beginner ones on RW.com - around 10 so am going to work through those over the next month to broaden my understanding of Swift. Start Time - 12:56 This is what I will be following, tutorial/article wise - https://www.raywenderlich.com/5055364-ios-storyboards-getting-started *By the way, the timings they give would most likely be if you were reading through, rather than doing and actively learning like I am! This will probably be in two different entries, and as usual I will type what I am finding out as we go along. A key difference here is having no audio - that will be a bit of a challenge in terms of information being reinforced etc. One of the benefits is having multiple view controllers. I've found this before - compared to the previous Xcode. This is now what the storyboard can look like - Purpose of this tutorial: building an app called 'Ratings': players, the games they play an...

RayWenderlich.com Layout in IOS Course - Part 6

Here we go! The final chapter. Possibly two entries but I may be able to do it in one. Then the Auto Layout is complete. As always I will do a consolidation entry. This chapter is all about constraints.  Start time - 13:35 Intro Attributes can be added - position, width and height Some of this is implied e.g. if you give the leading (left) and trailing (right) edges, then the width is derived from those Formulas are used to work out the position, width and height. Top and bottom Layout guide - keeps tab bars etc. separate. Stack views are usually the best way to set up views but constraints still needed. Add New Constraints So some cool shortcuts - add multiple heights/weights in one go. Do the whole make same height feature, based on one constraint already in. Minimum font scales - great if text is too big, then it will work on multiple devices. Drag Constraints Ok, so selecting options in the attributes - in this case centre horizontally and vertically ...

RayWenderlich.com Layout in IOS Course - Part 5

Image
It's been a while but for god reason! I've got a promotion at work, which means I've really got my future set. However, I am not going to abandon Swift. My work over the past 20-ish months has been rewarding and to let all of that go would be a shame. True, had I not got the promotion, I would probably be gravitating towards Swift more with an aim to transition to a career in the future. Anyway, that COULD still happen but it does make me want to rethink my goals a bit. We're also on an early holiday, so plenty of time to code and do a reflective entry of where I am and where I want to be. That will happen soon! For now, let's get on with the auto layout course! Start Time - 9:42 Intrinsic Content Size So this is the size that will fit EXACTLY into a a view's content. Content Hugging and Compression Resistance - these are rules that show the importance of contents not shrinking or resizing, bigger than the intrinsic size. 4 priority values to set. Vert...

RayWenderlich.com Layout in IOS Course - Part 4

Image
Here we go! So the course is split into Swift UKit. Interface builder. Let's do this! Start Time - 20:32 Introduction About half an hour tonight I reckon. Translates masks into constraints - apparently this is the option to use. So the whole point of Auto Layout is so you can fit onto any device. Stack views are coming here too. Autoresizing Fixed attribute will not change. OK, a key point here is that the content is all on an older Xcode - Xcode 11. So the features are all quite different. Trying to follow along still! Ok, can't even find size inspector! No point doing this on this earlier version of Xcode. So skimming through instead. I get the concept of all of this. The use of constraints etc. Autoresizing mask - flexibilities. All of the different options! Stack Views OK I've found some of the main views again! Out of practice with Swift UIKit! Stack view is non-rendering. That means non visible. Not even a background. Spacing is an attr...

RayWenderlich.com Layout in IOS Course - Part 3

Some momentum again! I feel positive about the content I'm learning, even if some of it is very complex. Right, straight onto this - I was partway through a challenge. Let's crack on! Start Time - 18:41 Challenge: Custom Alignment Guides OK, something does not seem to be working with this particular project. Errors coming up so just following along to see what Jessy does. This alignment guide is very hard! So it is something I think to revisit at the end of the course. Definitely will need some going over! I didn't have a clue for this one but then there wasn't much of a chance, as even Jessy admits. He says that this is beyond the complexity for most, which is me at this stage! So I'm putting this challenge down to a 'too hard!'. But will have another look another time! ZStacks Has a lot in common with the other two stacks. Zstack represents the background of the view. It uses BOTH horizontal and vertical. 9 built in values to use. So a poin...