Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Getting an error connecting to target. Should be simple. Help please.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ukchucktown" data-source="post: 1204003" data-attributes="member: 129039"><p>Usually you need to register a control with a target. You can do it from code or interface builder. You can checkout the API docs for UIControl. There you will find an addTarget method. That's what you need to call on the control reference to register the callback method (action) with the control. I pasted some sample code so you can see how to call the addTarget method from a controller class.</p><p></p><p>- (void)setupControls {</p><p> [mySlider addTarget:self action<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(updateVolume)</p><p> forControlEvents:UIControlEventValueChanged];</p><p> [myButton addTarget:self action<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(hitOrMiss)</p><p> forControlEvents:UIControlEventTouchUpInside];</p><p>}</p></blockquote><p></p>
[QUOTE="ukchucktown, post: 1204003, member: 129039"] Usually you need to register a control with a target. You can do it from code or interface builder. You can checkout the API docs for UIControl. There you will find an addTarget method. That's what you need to call on the control reference to register the callback method (action) with the control. I pasted some sample code so you can see how to call the addTarget method from a controller class. - (void)setupControls { [mySlider addTarget:self action:@selector(updateVolume) forControlEvents:UIControlEventValueChanged]; [myButton addTarget:self action:@selector(hitOrMiss) forControlEvents:UIControlEventTouchUpInside]; } [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Getting an error connecting to target. Should be simple. Help please.
Top