material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

[BottomSheet] Bottom Sheet cannot be expanded

Open blastervla opened this issue 4 years ago • 10 comments

Description

I'm not being able to get the bottom sheet component to actually extend, it always sits in the preferred position. However, I do acknowledge that whenever I swipe upwards, the sheet enters in the extended state (in fact I've set a different shape generator for both states), but it always stays in the exact same position of the screen.

As a note, I can clarify that the content ViewController isn't fully displayed in this state (i.e: it would need the sheet to extend a bit more than it does to display correctly all the information). All vertical constraints are correctly attached to the superview, so intrinsic content size isn't an issue.

I've also tried embedding my content in a scroll view, but to no avail. The only difference is that when the scrollview is present the sheet loses the capability of being dragged to dismiss, but won't move even an inch when scrolling. I have also tried setting the trackingScrollView property.

Reproduction steps

  1. Create a new ViewController, with a nib file attached.
  2. Add a UIView to the controller in the nib file, attach constraints to the parent (leading, trailing, top, bottom)
  3. Add a height constraint to the added view, set it to something gargantuan like 1000 (or 10000 if you're feeling extreme 🔥)
  4. Set ViewController frame height to that number too, in order to fix constraint issues.
  5. Open up a new BottomSheet displaying that controller with the following code: <ParentViewController>.present(MDCBottomSheetController(contentViewController: <TestViewController>()), animated: true)
  6. Note that you can drag all you want, but the content controller will have its content cut at the same spot, always. 😢

Expected behavior

The bottom sheet should let you drag upwards so as to extend it to be able to see the rest of the content. Furthermore, shouldn't that be enough to display it, the user should also be able to keep scrolling upwards and the rest of the content should be revealed, just like a scroll view.

Actual behavior

The bottom sheet just sits idle in the same spot of the screen. Dragging generates a bouncing effect, but nothing else happens other than that, and the content is trimmed. Internally the bottom sheet does transition into the extended state, but that isn't reflected in the height and position of the sheet (but it is in its corners, if a custom shape generator is being used).

Platform (please complete the following information)

  • Device: iPhone XR (simulator)
  • OS: iOS 12.2

Additional context

Here are two beautiful GIFs (ノ◕ヮ◕)ノ*・゚✧

Without scrollview With scrollview
No ScrollView WithScrollView

blastervla avatar Mar 18 '20 22:03 blastervla

hi Mr.blastervla , how to import MaterialComponent( pod 'MaterialComponents/BottomSheet') I use pod install, but error Can you support? Thanks Mr.blastervla

This my error:

JSON::ParserError - 416: unexpected token at '{ "name": "MaskedTransition", "platforms": { "ios": "8.0" }, "public_header_files": "components/MaskedTransition/src/.h", "source_files": [ "components/MaskedTransition/src/.{h,m}", "components/MaskedTransition/src/private/*.{h,m}" ], "dependencies": { "MotionTransitioning": [ "> 3.0" ], "MotionAnimator": [ "> 1.0" ], "MotionIntercha' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in parse' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in parse' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.1/lib/cocoapods-core/specification/json.rb:61:in from_json' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.1/lib/cocoapods-core/specification.rb:742:in from_string' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.1/lib/cocoapods-core/specification.rb:716:in from_file' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.1/lib/cocoapods-core/source.rb:186:in specification' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver/lazy_specification.rb:37:in specification' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver/lazy_specification.rb:29:in subspec_by_name' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:362:in block in specifications_for_dependency' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:362:in map' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:362:in specifications_for_dependency' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:165:in search_for' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:274:in block in sort_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:267:in each' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:267:in sort_by' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:267:in sort_dependencies' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/delegates/specification_provider.rb:53:in block in sort_dependencies' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/delegates/specification_provider.rb:70:in with_no_such_dependency_error_handling' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/delegates/specification_provider.rb:52:in sort_dependencies' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:288:in initial_state' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:210:in start_resolution' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:168:in resolve' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in resolve' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/resolver.rb:94:in resolve' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:1065:in block in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:1063:in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:124:in analyze' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:410:in analyze' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:235:in block in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:234:in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:156:in install!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command/install.rb:52:in run' /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:52:in run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in <top (required)>' /usr/local/bin/pod:23:in load' /usr/local/bin/pod:23:in `

'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=416%3A+unexpected+token+at+%27%7B%0A++++++%22name%22%3A+%22MaskedTransition%22%2C%0A++++++%22platforms%22%3A+%7B%0A++++++++%22ios%22%3A+%228.0%22%0A++++++%7D%2C%0A++++++%22public_header_files%22%3A+%22components%2FMaskedTransition%2Fsrc%2F%2A.h%22%2C%0A++++++%22source_files%22%3A+%5B%0A++++++++%22components%2FMaskedTransition%2Fsrc%2F%2A.%7Bh%2Cm%7D%22%2C%0A++++++++%22components%2FMaskedTransition%2Fsrc%2Fprivate%2F%2A.%7Bh%2Cm%7D%22%0A++++++%5D%2C%0A++++++%22dependencies%22%3A+%7B%0A++++++++%22MotionTransitioning%22%3A+%5B%0A++++++++++%22~%3E+3.0%22%0A++++++++%5D%2C%0A++++++++%22MotionAnimator%22%3A+%5B%0A++++++++++%22~%3E+1.0%22%0A++++++++%5D%2C%0A++++++++%22MotionIntercha%27&type=Issues

If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods... Searching for inspections failed: undefined method `map' for nil:NilClass

VietNamBookingApp avatar Apr 01 '20 03:04 VietNamBookingApp

Can you support?

Hi VietNamBoookingApp, I suggest you check here as the problem seems to be very similar to yours.

Note: I do not work at Google, nor at the Material Components lib, so I may not be the ideal person to ask to, but hopefully this helps 😄

blastervla avatar Apr 01 '20 12:04 blastervla

@VietNamBookingApp removing the .cocoapods/repos/trunk and run pod install solved this issues for me.

carlosmonzon avatar May 13 '20 04:05 carlosmonzon

Please remove the cocoapods issue from this thread, i'am interested in the real issue and not in other non-related issues.

UP for the [BottomSheet] Bottom Sheet cannot be expanded #9938

firetrap avatar Jul 09 '20 14:07 firetrap

Any updates on this issue?

Thecrazyskull avatar Jul 13 '20 17:07 Thecrazyskull

@wenyuzhang666 @randallli

Thecrazyskull avatar Jul 15 '20 11:07 Thecrazyskull

I ran into this issue as well. I resolved it by ensuring the root view of my content UIViewController was the UIScrollView instead of the default UIView.

Then, ensuring that my UIScrollView child view has it's edges pinned to the UIScrollView (specifically the bottom edge).

I use SnapKit, so here what it looks like in SnapKit

scrollView.addSubview(verticalStackView)
verticalStackView.snp.makeConstraints { constraints in
    constraints.left.equalToSuperview()
    constraints.top.equalToSuperview()
    constraints.width.equalToSuperview()
    constraints.bottom.equalToSuperview()
}

The root view probably doesn't have to be a UIScrollView but I found it was easier that way in my case. I believe if you at least ensure the root view of your content UIViewController is equal to the height of the actual content you're trying to display, it should work.

alexfu avatar Nov 04 '20 20:11 alexfu

I'm facing the same problem here. Using a TableView as my scrollView to track. My tableView is pinned to the screen:

        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }

chrsp avatar Dec 12 '20 00:12 chrsp

Facing the same problem here

mariorsjr avatar Jan 22 '21 14:01 mariorsjr

I had the same issue and it turned out that I was passing a nil when assigning the trackingScrollView. My code went something like this:

let storyboard = UIStoryboard(name: "myStoryboardName", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "ControllerName")
let bottomSheet = MDCBottomSheetController(contentViewController: controller)

bottomSheet.trackingScrollView = controller.tableView

It completely escaped me that at this point tableView would not be instantiated because controller's loadView() had not been called yet - loading the view tree is triggered by the view getter. There might be a more elegant way but adding this line did the trick for me:

...
let dummyVariable = controller.view

bottomSheet.trackingScrollView = coursesController.tableView

dachev avatar Feb 17 '21 14:02 dachev