Comments (7)
For you information
I also tried putting this library in TabbarViewController class and hiding default tabbar. This loads perfectly but Does not scroll to higher position at all. Please advise something , what needs to be done in second case
Below is the code attached from your example
class CustomTabBarVC: UITabBarController {
var sheetCoordinator: UBottomSheetCoordinator!
var sheetVC: DraggableItem!
var useNavController = false
var dataSource: UBottomSheetCoordinatorDataSource?
override func viewDidLoad() {
super.viewDidLoad()
self.tabBar.isHidden = true
self.sheetVC = ListViewController()
self.dataSource = MyDataSource()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
guard sheetCoordinator == nil else {return}
print("Called from subviews")
sheetCoordinator = UBottomSheetCoordinator(parent: self)
if dataSource != nil{
sheetCoordinator.dataSource = dataSource!
}
let vc: UIViewController
if useNavController{
vc = UINavigationController(rootViewController: sheetVC)
sheetVC.title = "Navigation Bar Title"
}else{
vc = sheetVC
}
sheetVC.sheetCoordinator = sheetCoordinator
sheetCoordinator.addSheet(vc, to: self, didContainerCreate: { container in
let f = self.view.frame
let rect = CGRect(x: f.minX, y: f.minY, width: f.width, height: f.height)
container.roundCorners(corners: [.topLeft, .topRight], radius: 10, rect: rect)
})
}
}
from ubottomsheet.
@prashantAlgante I will try to look at it this week asap.
from ubottomsheet.
Hello @OfTheWolf Can you please also look for #36 . That will also be much simpler for you to do. Thanks
from ubottomsheet.
Edit: my fault. See my comment below
I think I have the same problem.
A MapViewController inside a UITabBarController
The MapViewController controller presents the Sheet controller.
This is an actual screenshot using UBottomSheet:
The SheetViewController has no UIScrollView
but implements Draggable.
I use this code from the MapViewController:
let dataSource = StackDataSourceProxy(viewController: transitPlanViewController)
self.stackDataSourceProxy = dataSource // strong reference
self.sheetCoordinator.dataSource = dataSource // weak reference
sheetCoordinator.addSheet(transitPlanViewController, to: self, didContainerCreate: { container in
let f = self.view.frame
let rect = CGRect(x: f.minX, y: f.minY, width: f.width, height: f.height)
container.roundCorners(corners: [.topLeft, .topRight], radius: 10, rect: rect)
})
sheetCoordinator.setCornerRadius(10)
Expected behaviour: scrolling on pan gesture.
Actual behaviour: not scrolling on pan gesture.
(availableHeight does not respect the tabBar height but that's easy to work around)
from ubottomsheet.
@prashantAlgante @GerdC
Interesting bug. It seems TabBarController causes child vc's viewWillAppear is not called. So as a workaround put all startTracking logics in viewWillLayoutSubviews.
//***ListViewController.swift***
var isTracking = false
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
if !isTracking{
isTracking = true
sheetCoordinator?.startTracking(item: self)
}
}
from ubottomsheet.
(availableHeight does not respect the tabBar height but that's easy to work around)
This should be the problem.
@GerdC
public var availableHeight: CGFloat{
if #available(iOS 11.0, *) {
return parent.view.frame.inset(by: parent.view.safeAreaInsets).height
} else {
return parent.view.frame.height
}
}
from ubottomsheet.
@prashantAlgante @GerdC
Interesting bug. It seems TabBarController causes child vc's viewWillAppear is not called. So as a workaround put all startTracking logics in viewWillLayoutSubviews.//***ListViewController.swift*** var isTracking = false override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() if !isTracking{ isTracking = true sheetCoordinator?.startTracking(item: self) } }
it was my fault, but your answer was a great help to find it.
I did not set the sheetCoordinator in the presented sheet, only in the presenting controller.
Will never happen again:
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let sheetCoordinator = self.sheetCoordinator {
sheetCoordinator.startTracking(item: self)
} else {
assertionFailure()
}
}
I don't think any more that there is a problem using UBottomSheet in a TabBarController.
You could add an assertion to your example code as I did to make it easy to find this type of mistake.
Thanks
from ubottomsheet.
Related Issues (20)
- how to set the top hight of the bottomSheet? HOT 1
- [Question]Easy to close HOT 1
- Issue in view HOT 1
- Odd blank area added in AppleMaps example HOT 1
- Issue with the bottom sheet when there's navigation bar with Translucent turned off.
- Dynamic height of Bottom Sheet HOT 1
- Is there any simple way to have it coming from top?
- Tap outside the sheet should close it HOT 2
- SwiftUI integration HOT 8
- Bug in velocity HOT 2
- Bottomsheet initial position wrong HOT 2
- Avoid using ! for sStrong.container reference HOT 1
- Default initial size
- sheetVC can not deinit HOT 1
- Can not drag search bar to move the sheet
- Add Completion Handlers to Sheets/Animations
- XCode 12.5 warning "Using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead"
- Is there a way to present the sheet over the tab bar? (or hide the tab bar before the sheet shows) HOT 2
- swipe gestures on the navigation bar would crash HOT 4
- Can the access control card be copied to the mobile phone?
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 ubottomsheet.