HW#17 Practice using page control,segmented control & button etc. to change contents

Goal: Using connecting elements to make images change

Tonight we have covered how to connect elements using IBAction & IBOutlet. This is is really cool because we could directly write code to add actions to the UI elements. Unlike what we did in Storyboard, just dragging the desired UI elements onto the interface builder, this class taught us how to write specific code to do the same functions.

In fact, I have tried to read other people’s works and got a bit of understanding. However, after Peter’s class, it became much clearer about the entire process. Here are some links I have come across as references:

With some thought, I decided to select Salt Lake City as my topic as I had fond memories over there when I studied at University of Utah. Salt Lake City is a very beautiful city with loads of Mormon influences. As their pioneers moved from the east to the west, they settled down in Utah and spent years building up this city. It’s not easy to search suitable photos on the Internet but I found some nice ones via the websits such as Pinterest & Flickr. I chose the years, 1900, 1920, 1940, 1960, 1980, 1990, 2000, & 2020.

This homework wasn’t easy as I tried several days to figure out from other seniors’ works prior to our lecture tonight. I reckon one essential thing is to connect the designated UI elements via the code I wrote in the func. Here is what one should pay attention to :

Now, let’s take a look at the code I added to make some outlets and actions work.

Part 1
Part 2
Part 3

By the way, in case sometimes you don’t see the assistant editor when you want to write the code. You can go to the menu to do as follows: Xcode →View →Reset Assistant Selection. Or you can close Xcode and run it again. I didn’t see the assistant editor at the beginning, so I went to View to select Reset Assistant Selection and it worked.

Lastly, let’s take a look at how it works on the Simulator.

It’s not the best design as I’m not that artistic and still trying to practice how to be adept at these new skills. There are other things I can add and I think I will do that for my future practice. As time goes by I shall become more familiar with what we have learnt in class. As for the code, I sort of imitated other seniors’ works. Thanks for their examples. Now, I am able to grasp more and more what the wording means in code, especially after Peter’s lecture. It’s awesome, indeed. Until next time, cheers!

--

--

Jerski
彼得潘的 Swift iOS / Flutter App 開發教室

Studied Linguistics in university and have been intrigued by code writing. Now this journey of Swift just began.