Closed tcheek-bw closed 5 years ago
@hoidofyolen Can you attach a screenshot of the debug view hierarchy? Are you still facing this issue?
Yes, still seeing this issue. Is this what you mean by debug view hierarchy? It's the only place I know that has debug information without hitting a breakpoint.
Nevermind, I found it. Here's what I think is the culprit constraint:
Very interesting... let me take a look and get back to you!
@hoidofyolen If you clone this repo and run the example app and in MainViewController.swift
comment out all of the cards except for the CardPartTableViewCardController()
and run, do you still see the same issue? Maybe this is only happening for ViewControllers pushed on the navigation stack.
@hoidofyolen i am looking in to this issue, alternatively u can add a CardPartSpaceView(height:10)
and then add the CardPartTableView
in the navigationController. some thing like below
setupCardParts([CardPartSpaceView(height:10),CardPartTableView() ])
@hoidofyolen just did a sanity check , works as expected , see the below code and attached screenshot.
class TestViewController: CardPartsViewController {
let cardPartTableView = CardPartTableView()
let viewModel = CardPartTableViewModel()
override func viewDidLoad() {
self.view.backgroundColor = UIColor.gray
cardPartTableView.margins.top = 120.0
viewModel.listData.asObservable().bind(to: cardPartTableView.tableView.rx.items) { tableView, index, data in
guard let cell = tableView.dequeueReusableCell(withIdentifier: "CellId", for: IndexPath(item: index, section: 0)) as? CardPartTableViewCell else { return UITableViewCell() }
cell.leftTitleLabel.text = data
return cell
}.disposed(by: bag)
setupCardParts([cardPartTableView])
}
}
When I implemented your line cardPartTableView.margins.top = 120.0
, I got this:
I am able to supplement the space in the top margin by using the spacer view. This is how I did it:
class SpacerViewController: CardsViewController {
override func viewDidLoad() {
super.viewDidLoad()
loadCards(cards: [SpacerCardController()])
}
}
class SpacerCardController: CardPartsViewController, NoTopBottomMarginsCardTrait, TransparentCardTrait {
override func viewDidLoad() {
super.viewDidLoad()
setupCardParts([CardPartSpacerView(height: 8)])
}
func requiresNoTopBottomMargins() -> Bool {
return true
}
}
No, the problem is still there, but I was able to use the temporary solution of using a transparent spacer view. But this shouldn't be the long-term solution for the platform.
Of course not. However, we are not able to reproduce the issue. We are seeing the top margin work appropriately. Is there possibly other constraints you are setting?
I don't have any other constraints set, as you can see from my screenshots. I think a little more effort should be put into trying to reproduce this issue, since it happens consistently for me. Maybe it has to do with having the view controller wrapped in a navigation controller?
@hoidofyolen We will continue to look into this issue
Hi,
When working with a single
CardPartTableView
, I would expect there to be a top margin of about 10.0 or so, but there is no margin. In the documentation it states that cards have a default margin all around them, but that doesn't seem to be true for the top margin of the first card in the view. As a result, this is what it looks like:I've tried implementing the
NoTopBottomMarginsCardTrait
protocol on myCardPartsViewController
subclass, and manually implementing therequiresNoTopBottomMargins()
method to returnfalse
, but no change. I tried to manually create aCardPartSpacerView(height: 30.0)
calledaboveSpacerPart
and included that in my array passed tosetupCardParts([])
, but that didn't make any difference either. I even tried to manually set the margins on theCardPartTableView
to this:tableViewPart.margins = UIEdgeInsets(top: 10.0, left: 14.0, bottom: 14.0, right: 10.0)
. For some reason, it doesn't seem like I can get there to be a margin on top of thisCardPartTableView
. Any reason why that might be so?