LayoutKit
LayoutKit copied to clipboard
TableView sample doesn´t work
Im getting "Extra argument synchronous in Call"
reloadableViewLayoutAdapter.reload(width: width, synchronous: synchronous, layoutProvider: { [weak self] in
return [Section(header: nil, items: self?.getFeedItems() ?? [], footer: nil)]
})
Im getting this as well. @nicksnyder
Hi Kyle, thanks for your feedback. Could you please provide the more information about this error? Is it a crash? Can you reproduce it every time? When does this happen? Which version of Xcode and simulator are you using?
Using code from the Sample, in a new Xcode project, Xcode 8.3 and Simulator iOS 10.3
class FeedCollectionViewController: UIViewController {
private var reloadableViewLayoutAdapter: ReloadableViewLayoutAdapter!
private var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: UICollectionViewFlowLayout())
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
collectionView.backgroundColor = UIColor.purple
reloadableViewLayoutAdapter = ReloadableViewLayoutAdapter(reloadableView: collectionView)
collectionView.dataSource = reloadableViewLayoutAdapter
collectionView.delegate = reloadableViewLayoutAdapter
view.addSubview(collectionView)
self.layoutFeed(width: collectionView.frame.width, synchronous: false)
}
private func layoutFeed(width: CGFloat, synchronous: Bool) {
reloadableViewLayoutAdapter.reload(width: width, synchronous: synchronous, layoutProvider: { [weak self] in
return [Section(header: nil, items: self?.getFeedItems() ?? [], footer: nil)]
})
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
layoutFeed(width: size.width, synchronous: true)
}
}
I get the following errors
1: Extra argument 'synchronous' in call
Which refers to this line,
reloadableViewLayoutAdapter.reload(width: width, synchronous: synchronous, layoutProvider: { [weak self] in
return [Section(header: nil, items: self?.getFeedItems() ?? [], footer: nil)]
})
In the example code, FeedCollectionViewController
extends from FeedBaseViewController
. In base class FeedBaseViewController
, getFeedItems()
provides an array of Layout
. Since your FeedCollectionViewController
is subclass of UIViewController
, could you post your getFeedItems()
?
@kylebrowning So the sample app builds successfully for you but when copied to a new project the code no longer builds?
@staguer Correct.
I changed self?.getFeedItems() to be a custom array of my layouts as well.
CC @jingwei-huang1 ^
It appears to not like my use of generics.
class CommonTableViewController<Item>: UIViewController {
var items: [Item] = []
@kylebrowning For layoutProvider
, it has to be (Void) -> T
. For the generics we are using, please refer to public struct Section<C: Collection>
. And also you can take a look on the existed example of layoutProvider
in func layoutOne() -> [Section<[Layout]>]
.
Please let us know if that resolves your issue.
Will do, Ill let you know.
Same issue. Works well in example project but when I try to call this method from my project i get the same error.
Solved by putting ?? []
after self?.getFeedItems()
still don't understand why this is causing the problem though. My getFeedItems method returns [Layout]
array.
Im getting Extra argument 'synchronous' in call
with the following code:
adapter.reload(
width: 100,
synchronous: true,
layoutProvider: {
return [
Section(
header: nil,
items: [LabelLayout(text: "Hello", config: { _ in })],
footer: nil
)
]
}
)