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 01-14-2010, 09:38 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 16
jjardim is on a distinguished road
Default UISlider and Real Time

I'm trying to use a UISlider to act as a Time limit. Problem is that the values go to .99 before flipping to 1.

My code so far is

int _min = (int)mySlider.value;
NSLog(@"Slider Int Minutes %i",_min);

NSString *str = [NSString stringWithFormat:@"%.02f",mySlider.value];
int stringLength = [str length];
NSRange range = NSMakeRange(0, stringLength);
NSString *newStr = [str stringByReplacingOccurrencesOfString:@"." withString:@":" options:NSCaseInsensitiveSearch range:range];

NSLog(@"Old String: '%@' --> New String: '%@'", str, newStr);


So the slider works, but I would like once the decimal place hits .60 it increases by 1 and resets the decimals to .00

Screenshot Attached.

Thanks,
Jason Jardim
Attached Images
File Type: jpg Screen shot 2010-01-14 at 10.33.42 AM.jpg (11.5 KB, 4 views)
jjardim is offline   Reply With Quote
Old 01-14-2010, 11:38 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 16
jjardim is on a distinguished road
Default Found the Answer

Quote:
Originally Posted by jjardim View Post
I'm trying to use a UISlider to act as a Time limit. Problem is that the values go to .99 before flipping to 1.

My code so far is

int _min = (int)mySlider.value;
NSLog(@"Slider Int Minutes %i",_min);

NSString *str = [NSString stringWithFormat:@"%.02f",mySlider.value];
int stringLength = [str length];
NSRange range = NSMakeRange(0, stringLength);
NSString *newStr = [str stringByReplacingOccurrencesOfString:@"." withString:@":" options:NSCaseInsensitiveSearch range:range];

NSLog(@"Old String: '%@' --> New String: '%@'", str, newStr);


So the slider works, but I would like once the decimal place hits .60 it increases by 1 and resets the decimals to .00

Screenshot Attached.

Thanks,
Jason Jardim


Just wanted to contribute back - here is what I did

int timerInt = (int)mySlider.value;

lblSliderValue.text = [NSString stringWithFormat:@"%02d:%02d", timerInt / 60, timerInt % 60];

I converted the UISlider properties to Seconds in IB
jjardim 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: 335
9 members and 326 guests
2Apps1Day, akacaj, Domele, michelle, NSString, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,886
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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