Вот кусок кода:
import UIKit
import RxCocoa
import RxSwift
import FTPopOverMenu_Swift
public let popoverShowLists: PublishSubject<([List], UIEvent?)> = PublishSubject<([List], UIEvent?)>()
private func setupPopoverShowList() {
popoverShowLists
.subscribe(onNext: { lists, event in
if let event = event {
let cellConfi = FTCellConfiguration()
cellConfi.textFont = UIFont.systemFont(ofSize: 18)
var cellConfis = Array(repeating: cellConfi, count: lists.count)
FTPopOverMenu.showForEvent(event: event, with: lists.map{ $0.name }, menuImageArray: nil, cellConfigurationArray: cellConfis, done: { selectedIndex in
print(selectedIndex)
}, cancel: {})
}
}).disposed(by: disposeBag)
}
public func getListOfLists(event: UIEvent?) {
print(event) // First Print event
URLRequest.loadRequestGET(resource: APIManager.getAllLists, tokenUser: User.token!)
.subscribe(onNext: { [weak self] response, result, error in
print(event) // Second Print event
switch response.statusCode {
case HTTPStatusCodes.OK.rawValue:
if let result = result {
self?.popoverShowLists.onNext((result.list, event))
}
case HTTPStatusCodes.BadRequest.rawValue:
if let error = error { print("[-] Error[\(error.opcode)] \(error.message)") }
default:
break
}
}).disposed(by: disposeBag)
}
@IBAction func selectListButtonAction(_ sender: UIBarButtonItem, event: UIEvent) {
getListOfLists(event: event)
}
Я пытаюсь отобразить всплывающее окно с содержимым ответа на мой запрос, который представляет собой простой список строк.
FTPopoverMenu нуждается в событии в параметре. К сожалению, я теряю значение события после выполнения моего запроса, поэтому мое всплывающее окно не отображается.
Первый отпечаток мероприятия:
Optional(<UITouchesEvent: 0x600002b8c6c0> timestamp: 196495 touches: {(
<UITouch: 0x7f8401715f10> phase: Ended tap count: 1 force: 0.000 window: <UIWindow: 0x7f8401516b60; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x6000017e0d50>; layer = <UIWindowLayer: 0x6000019ec580>> view: <_UIButtonBarButton: 0x7f8401617120; frame = (0 0; 49 44); tintColor = UIExtendedSRGBColorSpace 0.156794 0.261571 0.36564 1; layer = <CALayer: 0x6000019d7a60>> location in window: {31.5, 43} previous location in window: {31.5, 43} location in view: {19.5, 20} previous location in view: {19.5, 20}
)})
Второй отпечаток события:
Optional(<UITouchesEvent: 0x600002b8c6c0> timestamp: 196495 touches: {(
)})
Как я могу решить это? Спасибо :)