我有一个用3行文本启动的UILabel:
locationDescription = [[UILabel alloc]init];
locationDescription.numberOfLines = 3;
[locationDescription setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:locationDescription];
Run Code Online (Sandbox Code Playgroud)
然后我有一个扩展标签的按钮:
- (void)buttonPressed:(UIButton *)sender{
NSLog(@"Pressed");
[UIView animateWithDuration:1
animations:^{locationDescription.numberOfLines = 0;}
];
}
Run Code Online (Sandbox Code Playgroud)
标签的期望行为是让每个额外的行一次显示一个.标签扩展正常,但转换不是动画,所有行只是立即显示.
我错过了什么?
有一个 Postgres 9.6 表,其中包含以下列:
targettable
------------------------------------------------------------------
id | name | jsonbdata | class
------------------------------------------------------------------
1 | A | {"a":"1","b":"2","c":[{"aa":"1"},{"bb":"2"}]} | 1
2 | B | {"a":"2","b":NULL,"c":[{"aa":"3"},{"bb":"2"}]} | 1
3 | C | {"z":"1","y":"2"} | 2
Run Code Online (Sandbox Code Playgroud)
jsonbdata保存具有不同结构的 JSON 对象,但在同一个class.
问题:
我想将jsonbdata与 a 匹配的所有行提取class到一个空的新临时表中,其中包含每个顶级 JSON 键的列,并且需要一些帮助来构建我的查询。
我现在在哪里:
create temp table testtable (id serial primary key);
with testrow as (select * from targettable where class = 1 limit 1)
select * from jsonb_populate_record(null::testtable, (select to_jsonb(jsonbdata) from …Run Code Online (Sandbox Code Playgroud) 如何以最少的代码水平分配3个div?
我有3个具有相同类的div,我需要水平分布它们,每个div之间有19个像素的空间.
我的解决方案目前是给前2个div一个19像素的右边距,并为第3个div分配一个单独的类,使其左边距为19像素.
这可以完成工作,但我觉得可能有更好的方法.理想情况下,所有3个div仍然具有相同的类.
我在UICollectionView中为UIScrollView设置了一个UITapGestureRecognizer.我已将其配置为正确检测点击并触发我编写的方法,但如果我尝试将选择器设置为collectionView:didSelectItemAtIndexPath:程序在点击单元格时崩溃.
知道为什么会这样吗?
这有效:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
- (void) tapped:(UIGestureRecognizer *)gesture{
//some code
}
Run Code Online (Sandbox Code Playgroud)
这不起作用:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(collectionView:didSelectItemAtIndexPath:)];
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//some code
}
Run Code Online (Sandbox Code Playgroud) objective-c uiscrollview ios uitapgesturerecognizer uicollectionview
ios ×2
css ×1
html ×1
jsonb ×1
objective-c ×1
postgresql ×1
spacing ×1
sql ×1
uilabel ×1
uiscrollview ×1