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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-01-2011, 12:02 AM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
pacoo2454 is on a distinguished road
Default ios 3.1.3 having problems with button titles?

hello. ive been working on an app and up until now ive only been able to test it on ios 4+. i just recently gained access to a device running on 3.1.3 to test on as well and for some reason the titles for some buttons i have arent displaying, the buttons themselves are showing up but until i tap the screen, anywhere, they finally show up. has anyone else experienced this? as far as i can tell all of the code ive been using so far should be compatible from 3.0+

some extra info, the original device used for testing is an iphone 4 with 4.3 beta 3 installed and it works fine.

ive tested it on an iphone 3g with 4.2.1 installed and it worked fine.

the problem device is an iphone 3g with 3.1.3 installed.

this is how im setting up the buttons
Code:
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button1.frame = CGRectMake(20.0, 10.0, 125.0, 37.0);
	[button1 addTarget:self action:@selector(button1Pressed) forControlEvents:UIControlEventTouchUpInside];
	[button1 setTitle:@"Clear" forState:UIControlStateNormal];
	[self addSubview:button1];
pacoo2454 is offline   Reply With Quote
Old 03-01-2011, 12:37 AM   #2 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

I have an app that sets button titles and your code looks good. By any chance is your method not getting called? Try putting in a few NSLogs to see what is/isn't getting called. Also if it is getting called when you touch anywhere on the screen, maybe it has something to do with a touchesbegan/ended method.
Objective Zero is offline   Reply With Quote
Old 03-01-2011, 12:46 AM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
pacoo2454 is on a distinguished road
Default

thanks for the quick reply.
i went ahead and added NSlogs before and after the line that sets the title and they are both displayed in the console when it is supposed to be. anyways, the buttons themselves are showing up, when the app first launches the buttons show up as empty boxes, then as soon as i interact with the app in anyway(touch the buttons in question, tap an empty area of the screen, tap a textfield) the titles are showing up. as of now im not implementing touchesBegan anywhere in my app.
any other ideas?
pacoo2454 is offline   Reply With Quote
Old 03-01-2011, 12:57 AM   #4 (permalink)
mer
Registered Member
 
Join Date: Jun 2009
Location: San Jose, CA
Posts: 28
mer is on a distinguished road
Default

You're probably using a font that is available in iOS 4 but not in the earlier version.

Mark
mer is offline   Reply With Quote
Old 03-01-2011, 07:18 PM   #5 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
pacoo2454 is on a distinguished road
Default

well, as of now i havent even set any fonts up, so the default is just being used. but i went ahead and added this

Code:
button1.titleLabel.font = [UIFont systemFontOfSize:12];
and its still producing the same results.

also, the text eventually appears, so it can display the font, its just not displaying the text when the button is initially displayed on the screen.
pacoo2454 is offline   Reply With Quote
Old 03-01-2011, 07:26 PM   #6 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
pacoo2454 is on a distinguished road
Default

alright, i got it to work correctly but it seems a bit absurd.

i had to change it from this

Code:
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button1.frame = CGRectMake(20.0, 10.0, 125.0, 37.0);
	[button1 addTarget:self action:@selector(button1Pressed) forControlEvents:UIControlEventTouchUpInside];
	[button1 setTitle:@"Clear" forState:UIControlStateNormal]; <<<
	[self addSubview:button1];
to

Code:
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button1.frame = CGRectMake(20.0, 10.0, 125.0, 37.0);
	[button1 setTitle:@"Clear" forState:UIControlStateNormal]; <<<
	button1.titleLabel.font = [UIFont systemFontOfSize:12];
	[button1 addTarget:self action:@selector(button1Pressed) forControlEvents:UIControlEventTouchUpInside];
	[self addSubview:button1];
thanks for everyone's input. =D
pacoo2454 is offline   Reply With Quote
Old 03-01-2011, 07:44 PM   #7 (permalink)
mer
Registered Member
 
Join Date: Jun 2009
Location: San Jose, CA
Posts: 28
mer is on a distinguished road
Default

Sorry - I misread the original post when I mentioned the fonts. Glad it's working now.

Mark
mer is offline   Reply With Quote
Old 03-01-2011, 08:07 PM   #8 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
pacoo2454 is on a distinguished road
Default

actually, if you wouldnt have posted that id probably still be stuck. after moving that one line, i decided to remove the line setting the font, seeing as how i just wanted to use the default and it disappeared again! very weird.
thanks a lot =D
pacoo2454 is offline   Reply With Quote
Reply

Bookmarks

Tags
firmware 3.x, iphone 3.1.3, iphone 3g, uibutton, uibutton text

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: 362
18 members and 344 guests
Absentia, akphyo, apatsufas, BinHex, cpsclicker, dre, Error404, Gaz, gmarro, jeroenkeij, Kirkout, MarkC, mottdog, Music Man, PavelMik, teebee74, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

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