swift 如何从 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);
在这个question
适用于 Apple Watch 应用程序
我试过下面的代码
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.
扩展的 class 的 super 中删除视图的代码
谢谢。
在 WatchKit 中,您无法以编程方式删除对象。
您可以使用 setHidden: 属性
Hides or shows the interface object in your user interface.
func setHidden(_ hidden: Bool)
A Boolean value indicating the visibility of the object. Specify true
to hide the object. Specify false to show it.
Discussion
When you hide or show an object in your interface, WatchKit makes a
note to update the layout during the next refresh cycle. During that
cycle, WatchKit adjusts the layout to display only the currently
visible objects.
参考题:
Can I create a WatchKit app without a storyboard (entirely in code)?
Create imageView programmatically in Watch Kit
在 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);
在这个question 适用于 Apple Watch 应用程序
我试过下面的代码
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.
扩展的 class 的 super 中删除视图的代码谢谢。
在 WatchKit 中,您无法以编程方式删除对象。
您可以使用 setHidden: 属性
Hides or shows the interface object in your user interface.
func setHidden(_ hidden: Bool)
A Boolean value indicating the visibility of the object. Specify true to hide the object. Specify false to show it.
Discussion
When you hide or show an object in your interface, WatchKit makes a note to update the layout during the next refresh cycle. During that cycle, WatchKit adjusts the layout to display only the currently visible objects.
参考题:
Can I create a WatchKit app without a storyboard (entirely in code)?
Create imageView programmatically in Watch Kit