使用 JSPatch 目前遭遇两个问题,不知道如何解决?

2016-08-12 18:31:52 +08:00
 Dean

问题 1 使用 Masonry 写在 block 中链式方式实现的约束如何转成 js

[talkButton mas_remakeConstraints:^(MASConstraintMaker *make) {
     make.centerX.equalTo(self.topView.mas_centerX);
     make.width.equalTo(self.topView).multipliedBy(70/75.0);;
     make.height.equalTo(self.topView.mas_height).multipliedBy(88/210.0);
     make.centerY.equalTo(self.topicText.mas_centerY);
}];

问题 2 使用调用单例方法设置值一直出错

[[UserInfoManager sharedInstance] setPublishOrder:info];
//参数类型 NSDictionary

ps:目前使用 Xcode7.3 出现一个问题如果出现 jx 执行出错就卡死,必须杀进程,花费了大量的调试时间

5368 次点击
所在节点    iDev
12 条回复
songz
2016-08-12 21:00:04 +08:00
去微博 @ bang
Dean
2016-08-12 21:55:10 +08:00
@songz bang 是那位大神难道是开源库作者,微博好久不上了去找下帐号
jiyee
2016-08-12 22:31:07 +08:00
```
self.bottomButton().mas__remakeConstraints(block('MASConstraintMaker *', function(make) {
make.centerY().equalTo()(self.bottomView());
make.height().equalTo()(self.bottomView());
make.right().equalTo()(self.bottomView());
make.width().equalTo()(100);
}));
```

第二个不好判断。
expkzb
2016-08-12 22:40:30 +08:00
抛弃 Masonry 改用 PureLayout 就好了(逃)
xi_lin
2016-08-13 21:47:16 +08:00
1. https://github.com/bang590/JSPatch/issues/93
如果提前准备好宏包装的类的话会比较方便

2. 你这样写不对吧?你在 JSPatch 里是怎么写的?
amon
2016-08-15 11:47:56 +08:00
talkButton.mas_remakeConstraints(block('MASConstraintMaker*', function(make) {
make.centerX().equalTo()(self.topView().mas_centerX());
make.width().equalTo()(self.topView()).multipliedBy()(70 / 75.0);;
make.height().equalTo()(self.topView().mas_height()).multipliedBy()(88 / 210.0);
make.centerY().equalTo()(self.topicText().mas_centerY());
}));

直接使用 JSPatch Convertor 转换的,楼主可以试用下可行不。
另外文档中有关于 block 的写法。
fishcat
2016-08-26 11:26:01 +08:00
关注一下,第一需要展开可以看下 https://github.com/bang590/JSPatch/issues/109
fishcat
2016-08-26 11:28:18 +08:00
不好意思,我刚发现这个竟然没有编辑功能,习惯性的 control + enter
Masonry 调试好之后可以教教我, 第二个 应该比较好解决可以看一下 https://github.com/bang590/JSPatch/wiki
Dean
2016-08-26 17:43:59 +08:00
@fishcat Masonry 问题已解决,主要是注意方法名称带下划线的再添加下划线
```objc
talkButton.mas__remakeConstraints(block('MASConstraintMaker *', function(make) {
make.centerX().equalTo()(slf.topView().mas__centerX());
make.centerY().equalTo()(slf.topicText().mas__centerY());
make.width().equalTo()(slf.topView().mas__width()).multipliedBy()(70/75.0);
make.height().equalTo()(slf.topView().mas__height()).multipliedBy()(88/210.0);
}));
```
Dean
2016-08-26 17:45:25 +08:00
@amon 直接转换出来的方法名称有下划线没有变成两个下划线被 js 执行出错
fishcat
2016-08-29 09:18:08 +08:00
@Dean 谢谢楼主,却是没有问题,犯了跟 sd_webImage 同样的错误
cyanbox
2016-11-25 22:34:48 +08:00
UserInfoManager.sharedInstance().setPublishOrder(info);

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/298943

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX