当前位置:网站首页>Summarize the strange interaction between reader and live broadcast: review ShuangDi Technology
Summarize the strange interaction between reader and live broadcast: review ShuangDi Technology
2022-07-19 16:23:00 【dengjiangszhan】
With reference didi/DoKit
Scene one :
When developing a reader project , There's a problem ,
You need to pop up a menu when you click on the green area , Therefore, a View,
However , When sliding in this area , The sliding gesture is blocked by the green area , The gesture cannot be passed to the following UIPageViewController Of View On

describe
Above the reader , Shake and shake , Come out with a green menu
You can order , You can also drag
Dragging is below UIPageViewController Things about .
The gesture is blocked by the green view , Need a passthrough
Ideas :
Put the green view hitTest View , Give it to the reader you are reading , That page
Drag the green view like this , You can also slide
class GreenView: UIView{
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
var afterThat = next
while afterThat != nil{
if let tmp = afterThat as? ViewController{
if let target = tmp.pagedController.viewControllers?.first{
return target.view
}
}
else{
afterThat = afterThat?.next
}
}
return nil
}
}
At the same time, we should capture the click event of the green view ,
By reading the view controller of the page , To catch
class ContentCtrl: UIViewController {
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first, greenFrame.contains(touch.location(in: view)){
NotificationCenter.default.post(name: .hitGreen, object: nil)
}
}
}
scene 2:
Users are in the live broadcast room , Eat the melon
Here comes an important message , It must be handled by the user ,
The user exits the live broadcast room , Also show ,
At the same time, it does not affect the user to send gifts to the anchor

Pictured above , The user sees the message , You can also use a slide reader
( In the message area , Sliding is invalid )
The idea must be window,
Disengage the controller , Can also show
Achieve one , Create a new window
class MsgWindow: UIWindow {
init() {
let originX: CGFloat = 50
let width = UIScreen.main.bounds.width - originX * 2
// Fixed window size
super.init(frame: CGRect(x: originX, y: 100, width: width, height: 150))
clipsToBounds = true
layer.cornerRadius = 8
backgroundColor = UIColor.cyan
// promote zIndex
windowLevel = UIWindow.Level.statusBar + 100
isHidden = true
}
func show(){
// Necessary configuration for presentation
if windowScene == nil, let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene{
windowScene = scene
}
isHidden = false
}
}
Realization 2, Use the old window and View
class MsgView: UIView {
init() {
let originX: CGFloat = 50
let width = UIScreen.main.bounds.width - originX * 2
super.init(frame: CGRect(x: originX, y: 100, width: width, height: 150))
clipsToBounds = true
layer.cornerRadius = 8
backgroundColor = UIColor.cyan
// Set up z Index
layer.zPosition = CGFloat.infinity
isHidden = true
}
func show(){
// find key window,
// Put the view , Add to
let scenes = UIApplication.shared.connectedScenes
for sce in scenes{
if let windowScene = sce as? UIWindowScene, windowScene.activationState == .foregroundActive , let win = windowScene.windows.first{
isHidden = false
win.addSubview(self)
return
}
}
}
}
scene 3,
Users are in the live broadcast room , Eat the melon
Here comes an important message , It must be handled by the user ,
The user exits the live broadcast room , Also show ,
At the same time, it does not affect the user to send gifts to the anchor
This message , For a long
( In the message area , Sliding effective )
Ideas , Extended scenario 2 Of the 2 Kind of implementation

In a word , Limited the response range ,
Rewrote func point(inside
class MsgView: UIView {
let rect : CGRect = {
let originX: CGFloat = 50
let width = UIScreen.main.bounds.width - originX * 2
return CGRect(x: originX, y: 100, width: width, height: 400)
}()
let btnRect = CGRect(x: 10, y: 10, width: 50, height: 50)
init() {
super.init(frame: rect)
clipsToBounds = true
layer.cornerRadius = 8
backgroundColor = UIColor.clear
layer.zPosition = CGFloat.infinity
isHidden = true
let bg = UIView(frame: CGRect(origin: .zero, size: rect.size))
bg.backgroundColor = UIColor.cyan
bg.alpha = 0.5
addSubview(bg)
let btn = UIButton(frame: btnRect)
btn.backgroundColor = UIColor.red
btn.layer.cornerRadius = 8
btn.backgroundColor = UIColor.white
addSubview(btn)
btn.addTarget(self, action: #selector(hide), for: .touchUpInside)
}
@objc func hide(){
isHidden = true
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return btnRect.contains(point)
}
}
Why this message , no need scroll View ?
ha ha
meanwhile , Solved scenario one
In general
github repo
边栏推荐
- 2022/07 CSI tool installation process record
- 信创环境下达梦数据库唯一索引异常无法拦截DuplicateKeyException
- 基于二叉树的传球问题思考与推测
- Ch549/ch548 learning notes 1 - hardware design
- A long distance
- 新股民如何网上开户,网上开户安全吗?
- Ch549/ch548 learning notes 3 - UART
- 论文阅读 TEMPORAL GRAPH NETWORKS FOR DEEP LEARNING ON DYNAMIC GRAPHS
- 反馈性学习
- Anaconda的基本使用与在Pycharm中使用
猜你喜欢

MySQL - unique key constraint for table fields

Fiddler: add IP column

Csgo suddenly returns to the desktop, and other applications are unresponsive. How can we not restart and close it

Definition and usage of callback function and qsort function in C language

Fiddler:增加IP列

基于二叉树的传球问题思考与推测

干货!综合的公平冷启动推荐系统

基于深度学习的人脸识别闸机开发(基于飞桨PaddlePaddle)

CH549/CH548学习笔记7 - USB Device初始化

Ch549/ch548 learning notes 5 - SPI main mode
随机推荐
Compile error recipe terminated with error when referencing latex pictures under vscade Retry building the project.
CH549/CH548学习笔记9 - USB Device端点处理过程
STM32+A4988控制步进电机
Use of promise object in ES6 asynchronous programming
Force buckle 565 Array nesting
【单片机仿真项目】模拟开关灯(proteus原理图+keil代码)
[MCU simulation project] the nixie tube displays 0 to 5 in turn (Proteus schematic +keil code)
反馈性学习
BFD of HCNP Routing & Switching
【单片机仿真项目】LED 闪烁灯(proteus原理图+keil代码)
Reading notes: self cultivation of programmers - Chapter 2
新股民如何网上开户,网上开户安全吗?
论文阅读 TEMPORAL GRAPH NETWORKS FOR DEEP LEARNING ON DYNAMIC GRAPHS
探究阿里云物联网开发板1-Haas 100
NFT市场格局仍未变化,Okaleido能否掀起新一轮波澜?
Ugui source code analysis - iclipper
What is the difference between the then second parameter in promise and catch?
Fiddler:增加IP列
Amy's thinking
[dry goods] how much do you know about MySQL infrastructure design?