繁体   English   中英

如何快速从Apple Watch / Watchkit的Superview中删除视图

[英]how to remove view from superview in apple watch / watchkit in swift

在android中使用相同的可见性功能,例如

1) android:visibility="gone" // used to hide the control and as well as space
  (or)
  CONTROLNAME.setVisibility(View.GONE);
2)  android:visibility="invisible" // used to hide the control but it will take space
  (or)
  CONTROLNAME.setVisibility(View.INVISIBLE);

这是这个问题对苹果手表的应用

我在下面尝试过代码

splashscreenImage.removeFromSuperView()

[self.splashscreenImage addConstraint:[NSLayoutConstraint constraintWithItem:self.captchaView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0]];

[splashscreenImage removeFromSuperview]

以上都不对我有用。 请告诉我代码,以从WKInterfaceController扩展的类的super中删除视图。

谢谢。

在WatchKit中,您无法以编程方式删除对象。

您可以使用setHidden:属性

在用户界面中隐藏或显示界面对象。

func setHidden(_隐藏:布尔)

一个布尔值,指示对象的可见性。 指定true可以隐藏对象。 指定false以显示它。

讨论区

当您在界面中隐藏或显示对象时,WatchKit会记下要在下一个刷新周期中更新布局的注释。 在该周期内,WatchKit调整布局以仅显示当前可见的对象。

参考问题:

我可以创建没有情节提要(完全用代码编写)的WatchKit应用程序吗?

在Watch Kit中以编程方式创建imageView

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM