swift 添加main入口文件 略谈
来源:互联网 发布:java类的实例化过程 编辑:程序博客网 时间:2024/06/10 15:20
在AppDelegate的文件中
@UIApplicationMain
class AppDelegate:UIResponder, UIApplicationDelegate {
这样进行了注解那么问题来了,如果想要实现自己的main文件该怎么办呢?
import Foundation
import UIKit
class MyApplication: UIApplication {
overridefunc sendEvent(_ event:UIEvent) {
super.sendEvent(event)
print(event)
}
}
UIApplicationMain(
CommandLine.argc,
UnsafeMutableRawPointer(CommandLine.unsafeArgv)
.bindMemory(
to: UnsafeMutablePointer<Int8>.self,
capacity: Int(CommandLine.argc)),
NSStringFromClass(MyApplication.self),
NSStringFromClass(AppDelegate.self)
)
我这里给出一种实现方式注意:MyApplication的sendEvent在我点击手机屏幕的时候会执行两遍
<UITouchesEvent: 0x6180000e4f80> timestamp: 37129.3 touches: {(
<UITouch: 0x7fdd03701170> phase: Began tap count: 1 force: 0.000 window: <UIWindow: 0x7fdd06009f10; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x600000051d90>; layer = <UIWindowLayer: 0x60000002afe0>> view: <UIView: 0x7fdd03403160; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x61800002b2c0>> location in window: {215, 247.5} previous location in window: {215, 247.5} location in view: {215, 247.5} previous location in view: {215, 247.5}
)}
<UITouchesEvent: 0x6180000e4f80> timestamp: 37130.9 touches: {(
<UITouch: 0x7fdd03701170> phase: Ended tap count: 0 force: 0.000 window: <UIWindow: 0x7fdd06009f10; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x600000051d90>; layer = <UIWindowLayer: 0x60000002afe0>> view: <UIView: 0x7fdd03403160; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x61800002b2c0>> location in window: {215, 247.5} previous location in window: {215, 247.5} location in view: {215, 247.5} previous location in view: {215, 247.5}
)}
这是两遍打印的结果,从中可以看出这是点击开始 和 结束的两个事件- swift 添加main入口文件 略谈
- vue入口文件main.js
- Swift 属性观察 略谈
- 入口函数main
- mongodb - main 函数入口
- main函数入口
- main()程序入口
- MTK_6253平台坐标文件略谈
- main 函数的入口参数
- vc++ main系列入口函数
- window的入口函数main
- main WinMain入口函数比较
- main WinMain入口函数比较
- main WinMain入口函数比较
- STM32中的main函数入口
- java main(入口函数)应用
- docker源码入口main函数
- 入口文件
- 运维学习笔记401~565
- MySQL数据库九
- 机房架构
- 2017.4.27 道路游戏 思考记录
- POJ2236 Wireless Network
- swift 添加main入口文件 略谈
- LeetCode 464 Can I Win 题解
- 《RabbitMQ实战:高效部署分布式消息队列》读后感
- 动态数码管显示
- 服务-dchp
- 近期计划
- C#基础枚举类型
- java通用方法equals、hashcode的重写注意事项
- PHP学习(1)