Post

Replies

Boosts

Views

Activity

Calling an object.method as variables
Hello! Back again! I am maintaining an object-method pair as host object properties:     var target : Any? = nil     var action : Selector and desire to call the method at some point from my host object: if self.target != nil { (self.target)?.action } For my attempted call, Xcode is giving me the error: Type of expression is ambiguous without more context I have tried various methods of calling the method to no avail. My research in the documentation isn't revealing the right way to do this. Can you please help me figure it out? Thank you all!
2
0
321
Dec ’21
Reference to currently active window
Hello! I have spent the larger part of the day trying to determine how to get a reference to the currently active window, in a one-scene app running on iOS 15, so that I can access a reliable reference to the rootViewController. Before 'scenes' came along we used this: ctrlr = UIApplication.shared.keywindow.rootViewController Now, thanks to Apple extending iOS to support multiple instantiations of a running App, that method is deprecated and I can no longer figure out how to get a reference to current-scene/current-window. Please help me out here. I'm at a complete loss, after hours of research into the docs and forums. Thank you!
6
1
6k
Nov ’21
Using .center to move a subview within its parent
Hello All! Everything I've read (Xcode online docs, iOS programming manuals, etc.) indicate that the best way to move a subview within its parent is to change its .center (.x or .y) property. I have been trying to figure this out for a bit now and the only way I can make a subview move is to change the .frame.orgin of its parent, which moves all the subviews - not what I want. Why can't I make changing .center work in the following code snipet (self is the parent View Controller)? // Load POI menus let poiMenus = Bundle.main.loadNibNamed("POIMenuViews", owner: nil)! let primaryPOIMenu = poiMenus[0] as! UIStackView self.view.subviews[0].addSubview(primaryPOIMenu) // works down to here primaryPOIMenu.center.x += 88   // This NO WORKY!!!  Why??? NOTE: The primaryPOIMenu.center.x IS changing (confirmed) but the subview is not moving. I tried using .center similarly in another place and that subview didn't move either. I'm very confused - this should be simple. Thanks in advance.
4
0
977
Oct ’21