我尝试将 UIPicker 的属性设置为 SetHidden:False 和 SetVisible:NO ,但它们仍然可见。
3 回答
嗯,你应该使用“setHidden”,而不是“setVisible”,你应该使用“YES”,而不是“False”或“NO”,所以尝试“setHidden:YES”,如果 UIPicker 在 Interface Builder 中正确连接它应该可以工作.
请直接从 XCode 复制代码,而不是重新输入。它是带有小“s”而不是大写“S”的“setHidden”。
[picker setHidden:YES];
Or picker.hidden = YES;
Don't forget that if you had dragged & dropped a UIDatePicker object onto your view using Interface Builder, you must link your object to the defined variable. You can do that by holding the CTRL button while dragging from your UIDatePicker object on your view to the File's Owner. I actually forget to do that more often than not. I end up programmatically creating my objects and adding them as subviews as a result.
您是否创建了 IBOutlet 并为引用插座设置了链接?