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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-14-2010, 12:10 PM   #2 (permalink)
Oliver Drobnik
Dr. Touch Cocoa Helpdesk
iPhone Dev SDK Supporter
 
Join Date: Sep 2008
Location: Vienna, Austria
Posts: 537
Oliver Drobnik is on a distinguished road
Send a message via AIM to Oliver Drobnik Send a message via MSN to Oliver Drobnik Send a message via Skype™ to Oliver Drobnik
Default

Quote:
Originally Posted by Ironcladmvtm View Post
i am working on a quiz game app... but i want the UIButtons to be dynamicly filled from the table of answers.

i am very new to iphone dev and development in general... only been working with objective-c for about a month.

i have tried "UIButton.text =" this is surely a beginners mistake
could anyone point me in the right direction?

Thanks in advance for any help!

Depends what kind of button, you can also combine it with foreground and background images.

But a simple button you create programmatically:

Code:
UIButton *oneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; // autoreleased
then you set the text:

Code:
[oneButton setTitle:@"Text" forState:UIControlStateNormal];
finally you need to add the button to the a view so that it get's displayed and retained.

Code:
[anyView addSubview:oneButton];
ah and you might want to set the button's dimensions. You can do this before or after the addSubview:

Code:
oneButton.frame = CGRectMake(x, y, w, h);

the buttonWithType class methods makes a autoreleased instance, the addSubview increases retain count to two. Then the autorelease pool draining reduces it to one.

when you finally call

Code:
[oneButton removeFromSuperview];
it disappears both from the screen as well as memory because this decreases the retainCount to 0 = dealloc.
__________________
regards

Oliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.

Linguan – makes localizing strings file fun!

Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!
Oliver Drobnik is offline   Reply With Quote
 

» Advertisements
» Online Users: 442
16 members and 426 guests
baja_yu, David-T, edvaniojancy, esoteric, HemiMG, iAppDeveloper, iGuessSo, jcfisher, jimmyon122, mediaspree, PixelEnvision, Punkjumper, RickSDK, Sloshmonster, speed4mee, thebeast
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,431
Threads: 94,026
Posts: 402,587
Top Poster: BrianSlick (7,978)
Welcome to our newest member, edvaniojancy
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:12 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.