Comments (4)
Hum it would be possible, but as this operator can take any gesture recognizer, I don't feel comfortable by overriding it's delegate. I could check if there's already a delegate and set it to RxGestureRecognizerDelegate
only if there isn't already one, but I don't really like this.
What you could do is to use it by yourself:
let gesture = SpecializedGestureRecognizer()
let delegate = RxGestureRecognizerDelegate()
gesture.delegate= delegate
view.rx.gesture(gesture).when(.recognized).subscribe(onNext: { g in
...
})
But you'll have to maintain a strong reference to it, otherwise it will be dealloc immediately because gesture.delegate
is a weak reference.
from rxgesture.
@JohnEstropia I don't understand...
RxGesture supports all gestures defined by UIKit.
Also, the API is extensible so if in your projects, you want to support your own gesture recognizer, it's possible.
You can do:
let gesture = SpecializedGestureRecognizer()
view.rx.gesture(gesture).when(.recognized).subscribe(onNext: { g in
...
})
You can also implement the same shortcuts as ones provided by RxGesture with native recognizer. You can inspire yourself with this implementation: https://github.com/RxSwiftCommunity/RxGesture/blob/master/Pod/Classes/iOS/UITapGestureRecognizer%2BRxGesture.swift
from rxgesture.
Sorry if I wasn't clear. First, thanks for mentioning the gesture(...)
factory method that accepts a UIGestureRecognizer
instance directly, I am now using that for my implementation.
I guess when I first asked the question I was looking for a factory method that lets me configure the RxGestureRecognizerDelegate
without having to create my own concrete GestureRecognizerFactory
. Now I found the gesture(_:)
method, my suggestion now is wouldn't it be convenient to have an overload method gesture(_:configuration:)
where we can configure the RxGestureRecognizerDelegate
policies?
from rxgesture.
@JohnEstropia Hey,
I think this should be doable now with RxGesture 2.x:
class MyCustomGestureRecognizer : UIGestureRecognizer {
// ...
}
public typealias CustomGestureConfiguration = Configuration<MyCustomGestureRecognizer>
public typealias CustomGestureControlEvent = ControlEvent<MyCustomGestureRecognizer>
public typealias CustomGestureObservable = Observable<MyCustomGestureRecognizer>
extension Factory where Gesture == GestureRecognizer {
public static func custom(configuration: CustomGestureConfiguration? = nil) -> AnyFactory {
return Factory(configuration: configuration).abstracted()
}
}
public extension Reactive where Base: View {
public func customGesture(configuration: CustomGestureConfiguration? = nil) -> TapControlEvent {
return gesture(Factory(configuration: configuration))
}
}
from rxgesture.
Related Issues (20)
- 3.0.1 not tagged & unavailable in CocoaPods HOT 4
- Build error on Xcode 11 GM with Swift Package Manager HOT 5
- Xcode 11 and Carthage: exit code 65 (compile error: use of undeclared type 'Element') HOT 8
- Gesture translation to identify when ended
- Release 3.0.2 to CocoaPods Repository HOT 1
- Inconsistency between release tag and podspecs
- Add XCode 11.4 recommended project settings
- Cannot build with `swift build`
- RxSwift 6 support
- Unable to build 4.0.0 with Carthage HOT 4
- Build Failed for SPM (version 4.0.0) HOT 3
- Why set isUserInteractionEnabled = true? HOT 4
- Can't pass Xcode 12.5.1 build
- s
- Broken build on macOS after changes in 4.0.3
- a minimum deployment target of iOS 12.0 HOT 3
- Privacy Manifest and Signature Request HOT 2
- tapGesture in subview and self both triggered HOT 2
- RxGesture podspec does not specify a Swift version. HOT 1
- Swiftlint proposal HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxgesture.