Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 03-12-2010, 12:05 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Location: Benicia, CA
Age: 49
Posts: 147
Default Attaching UIButtons in IB to an array?

I have a set of ten UIButtons in a nib, and a UIButton[10] array defined in the corresponding ViewController's .h file. However, I can't connect any of the buttons to the array (in either direction) in IB. Is there a way to do it in code without having to define a separate IBOutlet entry for each button?

I realize I can create a method to handle a TouchUpInside and use the sender argument to determine which button was clicked, but I am trying to do something that will modify the buttons when the app is first loaded.

(The array is defined as IBOutlet UIButton *buttons[10], in case it is some Objective-C problem involving an array of pointers vs a pointer to an array.)

-- Don
That Don Guy is offline   Reply With Quote
Old 03-21-2010, 12:44 AM   #2 (permalink)
Knows SQL
 
iisword's Avatar
 
Join Date: Oct 2009
Location: Somewhere the streets are on fire, the sewers are flooded, and the cats are high on catnip
Posts: 527
Default

You don't define arrays as IBOutlet. IBOutlets are things that you can put on the interface(buttons, label, views).

Probably a good way is to change the tags of the button to numbers in interface builder. Then all you got to do to access the tag is something like...

Code:
sender.tag
Someone back me up if this is right cause I think it will work...

I think the [sender titleForState:UIControlStateNormal] might also help define your buttons
__________________

Last edited by iisword; 03-21-2010 at 12:47 AM.
iisword is offline   Reply With Quote
Old 03-21-2010, 11:38 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 2
Default

Code:
UIButton *button = sender;
button.tag
XCode doesn't know what class sender is. So you have to declare a pointer with the same type as whatever object you are trying to use.
Marmadukian is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 239
19 members and 220 guests
ADY, AragornSG, BrianSlick, Dani77, Dattee, dre, glenn_sayers, HemiMG, JasonR, karlam963, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister, viniciusdamone, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:20 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0