This article is reprinted from the WeChat public account "AirPython", the author is Xing Anguo. Please contact the AirPython public account to reprint this article. 1. IntroductionHello everyone, I am Anguo! After writing a crawler in Python, sometimes we need to schedule the crawler in real time on the mobile phone, or display the crawler results in real time. In this scenario, we can write the crawler logic as an API and deploy it to the server, then write an App on the mobile terminal and directly call the interface through the interface element controls. In this article, we will talk about how to quickly write an iOS native App. 2. PreparationTo implement native iOS applications, we need to use Xcode on Mac to write and compile First, set up an Xcode developer account Open Xcode, select Xcode - Preferences - Accounts in the upper left corner, click the + sign in the lower left corner, and add a developer account Then, create a project using Xcode Select iOS App as the template, enter the project name, select "Swift" as the programming language, and click Next to complete the project creation. PS: Swift has a more concise syntax than OC Finally, specify the Sign signature for the newly created project If you have any questions about this part, you can click on the read original text at the end of the article to learn more. 3. Actual combatIn the actual combat part, we will explain it with a simple login page 3-1 Install dependent libraries Since the project is developed using Swift, it is recommended to use SPM (Swift Package Manager) to install dependencies. For example, the network request library "Alamofire" Project address: https://github.com/Alamofire/Alamofire Installation method: File - Swift Packages - Add Package Dependency - Enter the project address ( Github / Gitee ) - Select the installation version 3-2 Page Layout Open the "ContentView.swift" file in the project root directory and write the specific view under body First, use VStack to define a vertical layout box and define the child controls to be displayed horizontally in the center PS: The three common layout methods of SwiftUI are VStack, HStack, and ZStack, which represent vertical layout, horizontal layout, and depth layout respectively.
Then, the child elements add a local picture, two input boxes, a selection box, and a button in turn. in,
Finally, define variables and control data for two-way binding
3-3 Network request and result display Set a click event for the Button control, use Alamofire to make a network request, and finally write the result display to the result control and bind it to the data.
4. Final ThoughtsThis article describes the detailed steps of developing an iOS native application through a simple example; in actual applications, different functional modules can be customized and developed based on specific scenarios. |
<<: Create your own US App Store ID
>>: How to use iPad at work to improve work efficiency
Blockchain Hyperledger Enterprise Development Pro...
As a short content platform with strong sociality...
What if you want to gain 1 million followers in 7...
In Shandong, Liaoning, Zhejiang and other places,...
Autumn is the season of harvest. In the upcoming ...
Some people believe that being a vegetarian can h...
"For every hour of sitting, the average life...
Friends, do you still remember the NetEase H5 eve...
Author: Li Chuanfu Shi Xiangqi In the heart of th...
Offline support for mobile applications can be un...
Improve video quality in four aspects: picture, t...
[[217058]] uiautomator2 Android Uiautomator2 Pyth...
In fact, it is very simple to judge whether a per...
Review expert: Wang Xuejiang, professor at Capita...
The hosting server can be as small as possible Ev...