LayoutKit icon indicating copy to clipboard operation
LayoutKit copied to clipboard

TableView sample doesn´t work

Open FabianTerhorst opened this issue 8 years ago • 13 comments

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)]
            })

FabianTerhorst avatar Jul 04 '16 10:07 FabianTerhorst

Im getting this as well. @nicksnyder

kylebrowning avatar Apr 05 '17 15:04 kylebrowning

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?

jingwei-huang1 avatar Apr 05 '17 15:04 jingwei-huang1

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)]
        })

kylebrowning avatar Apr 05 '17 15:04 kylebrowning

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()?

jingwei-huang1 avatar Apr 05 '17 16:04 jingwei-huang1

@kylebrowning So the sample app builds successfully for you but when copied to a new project the code no longer builds?

staguer avatar Apr 07 '17 00:04 staguer

@staguer Correct.

I changed self?.getFeedItems() to be a custom array of my layouts as well.

kylebrowning avatar Apr 09 '17 20:04 kylebrowning

CC @jingwei-huang1 ^

kylebrowning avatar Apr 09 '17 20:04 kylebrowning

It appears to not like my use of generics.

class CommonTableViewController<Item>: UIViewController {
    var items: [Item] = []

kylebrowning avatar Apr 09 '17 20:04 kylebrowning

@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.

jingwei-huang1 avatar Apr 11 '17 19:04 jingwei-huang1

Will do, Ill let you know.

kylebrowning avatar Apr 11 '17 19:04 kylebrowning

Same issue. Works well in example project but when I try to call this method from my project i get the same error.

AlexBlack559 avatar Jun 24 '17 23:06 AlexBlack559

Solved by putting ?? [] after self?.getFeedItems() still don't understand why this is causing the problem though. My getFeedItems method returns [Layout] array.

AlexBlack559 avatar Jun 25 '17 00:06 AlexBlack559

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
      )
    ]
  }
)

aputinski avatar Oct 16 '18 16:10 aputinski