Figure 6-14 Button is hidden
Now, we have successfully located “compose” button, and its description is
<UIToolbarButton: 0x14798410; frame = (285 0; 23 44); opaque = NO; gestureRecognizers =
<NSArray: 0x14799510>; layer = <CALayer: 0x14798510>>. Next, we need to find out its UI
function.
- Find out UI function of “compose” button
UI function of a button is its response method after tapping it. Usually we use [UIControl
addTarget:action:forControlEvents:] to add a response method to a UIView object (I haven’t
seen any exceptions so far). Meanwhile, the method [UIControl
actionsForTarget:forControlEvent:] offers a way to get the response method of a UIControl
object. Based on this, as long as the view we get in the last step is a subclass of UIControl (Again,
I haven’t seen any exceptions so far), we can find out its response method. More specifically in
this example, we do it like this:
cy# button = #0x14798410
#"<UIToolbarButton: 0x14798410; frame = (285 0; 23 44); hidden = YES; opaque = NO;
gestureRecognizers = <NSArray: 0x14799510>; layer = <CALayer: 0x14798510>>"
cy# [button allTargets]
[NSSet setWithArray:@[#"<ComposeButtonItem: 0x14609d00>"]]]
cy# [button allControlEvents]
64
cy# [button actionsForTarget:#0x14609d00 forControlEvent:64]