0

I’m a novice working with an app that lets me bridge Lua to some objective C commands. Using that bridge, I’ve created some controls (e.g, a basic browser WKWebview) using the auto layout in iOS but now want to align some even simpler display items that I’ve created with the app’s Lua commands. Yet, my WKWebview positions are setup on the screen using layout constraints (e.g. Webview.bottomAnchor) while my simpler display items use simple x,y coordinates.

Is there a way that I can obtain the actual screen coordinates of my objective C Webview so that I can align my simpler display items to them (e.g. simpler display model below Webview: simpler display model position.x = Webview.anchorLeft; simpler display model position.y = Webview.anchorBottom)?

Thanks!

SugarRay
  • 21
  • 2
  • Why not also use auto layout constraints for your "simpler" display items? – DonMag Jan 17 '22 at 21:12
  • Thanks, @DonMag— the objective C bridge in the app is not yet mature enough for me to create everything I need in it (e.g. objective C bridge can not yet handle delegates whereas the base app has working handlers for simple display items like buttons so trying for now to mix and match display controls) – SugarRay Jan 17 '22 at 21:33
  • OK - does the bridge give you access to view controller lifecycle methods? In particular, can your Lua code receive the `viewDidLayoutSubviews` call? – DonMag Jan 17 '22 at 21:56
  • It looks like it should as method, and I can call the view controller. Can you provide me a code snippet suggestion as to how I would use that? I’ll then translate it to the bridge’s format and give it a try. Thanks. – SugarRay Jan 17 '22 at 23:12

1 Answers1

0

Thanks, DonMag, your clue about the viewDidLayoutSubviews helped me figure out the answer. From searching further online, I saw that I can get the actual coordinates of any UIView by getting extended properties on any UIView I made even if I aligned the view with an auto layout by scripting (in the example I proposed of aligning my simple Lua control under an objective C braided autolayout WebView UIView)

mySimpleControlPositionX = webView.frame.origin.x

mySimpleControlPositionY = (webView.frame.origin.y + webView.frame.size.height)

The stackoverflow.com answer that explains that I found that explained these extended properties of a UIView was at:

Cocoa: What's the difference between the frame and the bounds?

Thank you very much!

SugarRay
  • 21
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 18 '22 at 03:39