alibaba/VirtualView-iOS

layoutHeight、layoutWidth 设置表达式无效

Closed this issue · 1 comments

ljunb commented

话说该库还有在维护么?

本地运行 VirtualView-iOS 下的 RealtimePreview 工程,并启动了 virtualview_tools 下的服务,正常加载并运行 HelloWorld.xml 模板,但是调试发现 layoutWidth、layoutHeight 设置表达式是无效的:

<?xml version="1.0" encoding="utf-8"?>
<VHLayout
    orientation="V"
    layoutWidth="match_parent"
    layoutHeight="${itemH}"
    background="${bgColor}"
/>

其中 HelloWorld.json:

{
    "item": "300",
    "bgColor": "#ff0000"
}

实际并没有正确显示该 view。如果在 xml 中用字面量写死 layoutHeight,就能正常显示:

<?xml version="1.0" encoding="utf-8"?>
<VHLayout
    orientation="V"
    layoutWidth="match_parent"
    layoutHeight="300"
    background="${bgColor}"
/>
ljunb commented

试了改 TestViewController 的 viewDidLayoutSubviews 方法,问题解决:

~ - (void)viewDidLayoutSubviews {
      [super viewDidLayoutSubviews];
      self.scrollView.frame = self.view.bounds;
      CGFloat viewWidth = CGRectGetWidth(self.view.bounds);
      CGSize size = CGSizeMake(viewWidth, 1000);
+    [self.container updateData:self.data];
     size = [self.container estimatedSize:size];
     self.scrollView.contentSize = size;
     self.container.frame = CGRectMake(0, 0, size.width, size.height);
-    [self.container update:self.data];
+    [self.container updateLayout];
 }