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
Audit expert: Peng Guoqiu Deputy Chief Physician,...
This article will share with you an introduction ...
Accompanied by the huge controversy over "wh...
After the much-hyped "Lin Chiling and Yu Yon...
I have been engaged in the development of small p...
When doing Internet business, you must follow the...
Editor: Guru...
At the end of 2016, there were about 600 charging...
Ma Yue doesn't look like a company CEO, but m...
The meaning of advertising is publicity, but it i...
Just now, the top APP promotion company suddenly ...
1. Three characteristics of future consumption th...
Recently, the author discovered a "2018 Chin...
Nuclear energy Shandong Haiyang starts nuclear en...