问题标签 [componentkit]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
220 浏览

ios - CKComponent 更新而不改变模型

我有一些可以喜欢的故事元素的提要,就像 Facebook 一样。

我的第一步只是使用故事模型对象来获得喜欢的状态并在 CKButtonComponent 中显示它。该解决方案的问题在于该按钮不能足够快地代表预期的新状态。相反,我正在进行网络服务调用,该响应改变了故事,然后按钮被改变。

为了获得更快的按钮状态更改,我为该 CKComponent 构建了一个 CKComponentController ,它会在按下按钮时更新组件的状态:

此外,我正在拨打网络服务电话。该解决方案的问题在于,当我以足够快的速度多次按下like-Button时,应用程序崩溃并显示以下消息:

** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“未处理的组件操作 toggleLike 跟随响应者链 nil”

The crash happens at an Assert in void CKComponentActionSend(CKComponentAction action, CKComponent *sender, id context, CKComponentActionSendBehavior behavior) in the CKComponentAction class. I don't know why this happens only when i hit the button fast enough multiple times. It seems to have something to do with reload of all components which happens when the new story data get saved from the web service response. The reload of all components and at the same time the CKButtonComponent getting the touch event seems to lead to the crash.

The CKComponentAction of the CKButtonComponent is the described CKComponentController method toggleLike.

So what would be a good solution in this case? Is there a way to do this without changing the story model object?

I have also the feeling that my approach to use the state to override some model data (like status) is generally not really a good idea.

0 投票
2 回答
280 浏览

ios - 如何为具有多个参数的方法创建 CKComponentViewAttribute

我想为 UIButton 子类创建一个组件。要设置按钮,我想设置图像。我的问题是我不知道如何制作一个 CKComponentViewAttribute ,它采用 UIButton 方法所需的两个参数setImage:forState:

我试过这个:

但这不会编译。这个版本也一样:

我在这里读到http://componentkit.org/docs/advanced-views.html我需要将我的输入装箱到一个对象中。在这种情况下我该怎么做?

更新:我在这里找到了以下提示https://github.com/facebook/componentkit/issues/265

“CKComponentViewAttribute 可以用任意块初始化。这是一个例子:

"

这就是我最终设法解决问题的方法:

您可以内联以使其更短:

0 投票
2 回答
149 浏览

c++ - 如何右对齐第一个组件

我正在尝试实现以下布局:

我可以想象顶层是使用 CKStackLayout,但是对于每个条目,例如“姓名:詹姆斯”,我怎样才能使名称在框内右对齐?

我正在使用类似以下的内容,将文本包装在固定宽度的组件中并将标签组件设置为使用NSTextAlignmentRight对齐,但它不起作用,左右都只是“左对齐”:

谢谢!

0 投票
1 回答
85 浏览

ios - 如何将 UIGestureRecognizerDelegate 分配给 CKComponentController

我使用下面的代码在我的组件中设置 UIPanGestureRecognizer:

panGesture:context在 MyComponentController 对象中处理。

我的问题是UIPanGestureRecognizer阻止滚动提要视图。为了解决这个问题,我想使用UIGestureRecognizerDelegate协议并允许两个(滚动视图和我的平移)识别器同时工作。

我的问题是如何将我的组件控制器分配为代表UIPanGestureRecognizersetupPanRecognizer只是一个C function,它没有对MyComponentController对象甚至组件本身的引用。

我现在看到的唯一方法是didUpdateComponent在我的控制器的方法中的某处获取手势识别器列表,找到正确的并在那里分配委托。ComponentKit 是否为此提供任何解决方案?

0 投票
1 回答
307 浏览

ios - ComponentKit 和 FLUX 架构 - 避免不必要的 UI 重新渲染

我正在使用 Facebook ComponentsKit 来生成我的视图。

我现在正在迁移到用于更改应用程序状态和触发视图更新的“通量”架构。

我遇到的主要问题是并非所有状态更改都应该触发 UI 更新。我不明白避免这种情况的“通用”机制。

基本上,应用程序状态是一个代表“视图模型”的“大”“JSON”(解析为本机类型对象)。JSON 包含所有视图声明及其初始值。(JSON 相当复杂)

例如,一个简化的 JSON 表示包含“pager”组件和导航“next”按钮的视图层次结构:

我的“通量”抽象看起来像:

在我的“视图控制器”中,我现在得到一个“更新状态”回调

0 投票
0 回答
178 浏览

ios - 使用 Facebook Component Kit 实现简单的 uitableviewcell/collectionviewcell

目前,我已经用这样的普通 tableviewcell 实现了。

在此处输入图像描述

我现在正在研究组件套件,并希望像这种观点一样做某事。我正在阅读他们的示例 WildeGuess。使用组件套件的教程很少或没有教程。我应该如何实现将标签放在左上角,将 imageview 也放在左上角(我可以将 imageview 放在容器中,如示例)?

0 投票
2 回答
193 浏览

ios - iOS 在 CKLabelComponent 中创建属性标签,如 TTTAttributedLabel

我可以轻松地使用TTTAttributedlabel可点击的 url、名称等。

1)我怎样才能创建类似的东西CKLabelComponent

2)我需要使用CKTextComponent吗?

0 投票
1 回答
125 浏览

ios - 如何为 CKComponent (ComponentKit Facebook) 画线?

如何为 CKComponent (ComponentKit Facebook) 画线?

我可以使用基于 UIView 的类和 drawrect 方法来做到这一点。


但我怀疑是否有权像 CKStackLayoutComponent 的子组件一样使用基于 UIViev 的组件?也许有更好的方法?

提前感谢您的回复。

0 投票
1 回答
256 浏览

ios - 在 ComponentKit 中播放视频

我正在尝试使用 ComponentKit 显示视频。我希望它在点击组件时播放。我发现了这个Github Issue,所以我知道我需要使用 aCKStatefulViewComponent但我不知道处理点击事件的建议方法是使用 ComponentKit。

这是我到目前为止的代码:

0 投票
2 回答
1129 浏览

ios - ComponentKit 与 AsyncdisplayKit

我正在开发一个社交应用程序,有一个主要功能,“提要”。

到目前为止它适用于自动布局,一切都很好,但考虑到未来高级开发和维护的成本,我正在寻找其他异步 UI 解决方案。

我认为 ComponentKit,AsyncDisplayKit 是我正在寻找的

但哪一个更适合我?

它们都支持异步 ui 布局,以及网络图像占位符和缓存?

ComponentKit 和 AsyncDisplayKit 有什么区别?

哪一个更适合复杂的提要设计?

包括:快速原生/友好、异步 ui 布局、图像缓存和占位符、复杂的提要样式(垂直单元格中的水平单元格)...等