I am developing an iOS app using Rubymotion. I need to access a child label of a view to change it´s text.
How can I access child views (and their attributes) to modify them?
Thanks!
If you are using Xcode (Interface Builder) to design your views, then you'll want to use tagging to access your subviews. There are no properties
in RubyMotion. It is possible to use attr_accessor
to define the setter/getter for a property, but then there is no way to tell Interface Builder how to associate the control with the property name since Xcode doesn't understand the Ruby code. I have had success taking a project that was first written in Objective-C and using the .xib
and .storyboard
files in a RubyMotion project. In that case, if you create ivars
with the same names as the properties in Objective-C, then everything will work.
If you are creating your UIView
s programmatically, then you can store each subview in an ivar
before adding the subview to the view.