0

to use same visibility functions in android such as

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);

which is in this question for apple watch application

i have tried code below

splashscreenImage.removeFromSuperView()

and

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

also

[splashscreenImage removeFromSuperview]

non of above has worked for me. Please tell me code to remove view from super for a class which is extended from WKInterfaceController.

Thank you.

Community
  • 1
  • 1
Alp
  • 1,863
  • 1
  • 20
  • 38
  • 1
    Have you tried to set the hidden property to true? – dasdom Aug 11 '15 at 12:20
  • i didnt know there was such a property, trying right away. – Alp Aug 11 '15 at 12:21
  • thank you, its working for me, but i am still waiting for answer to remove view programitically – Alp Aug 11 '15 at 12:34
  • for my problem's solution ; in willActivate func {var timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("splashscreenAlpha"), userInfo: nil, repeats: false) }, and as func splashscreenAlpha() { splashscreenImage.setHidden(true) } – Alp Aug 11 '15 at 13:00
  • Could be that you can't remove it programatically, because WatchKit is very storyboard centric. File a radar if you think this should be possible. – dasdom Aug 11 '15 at 13:13

1 Answers1

1

In WatchKit you can not remove the objects programmatically.

You can use setHidden: property

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.

Reference Questions :

Can I create a WatchKit app without a storyboard (entirely in code)?

Create imageView programmatically in Watch Kit

Community
  • 1
  • 1
Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136