阅读背景:

以编程方式引用与接口构建器建立的对象

来源:互联网 

I have set up several Views each containing a UIPickerView each of which contains a UIToolbar, and each of which in turn has a UIBarButtonItem. All this is set up in IB. I have pointers to the UIPickerViews in the code. I am needing to reference the UIBarButtonItems as part of a function that behaves differently depending on which of the UIPickerViews it is dealing with. I have the (id) sender as an argument to this function. The sender is always one of the UIBarButtonItems. I am trying to find which UIPickerView this particular UIBarButtonItem belongs to. I assume that I have to start up the UIPickerView hierarchy and work down to the UIBarButtonItem. I think this is the correct approach because I cannot do a simple compare since I have no explicit reference to the UIBarButtonItem object since it was set up in IB. Further, because the subviews do not have a pointer to their parent view I cannot work my way back up the hierarchy. Correct? If I am correct in my thinking to this point, do I: traverse the view hierarchy in each UIPickerView, find a UIToolBar and then find a UIBarButtonItem? What exactly do I check for at both the UIToolBar level and the UIBarButtonItem level - I mean do I perform an if statement checking to see if the object is of type UIToolBar or UIBarButtonItem respectively? How do I find the type of an object in an if statement? I have set up several Views each containing a U




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: