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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-10-2008, 04:04 PM   #1 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 3
Default Slider transformation makes it invisible

Hello,

First off, my app is setup using multiple XIB files like myersn024 has in his tutorial iPhone Tutorial - Multiple XIB files on Vimeo

The app launches into landscape mode, and everything works just fine except for the slider, which I want to be vertical. I want the slider to automatically transform into vertical at the same time the app launches and goes into landscape mode.

My question is: Into which function do I put the transform code?

I can put the transform code under a button in the UIView, and when I tap it, it does the transformation just fine. But that's not the automatic functionality I'm looking for.

If I put the code into awakeFromNib in UIView, it does the transform, but the slider is invisible! If I slide my finger up and down where it should be, I see the values changing in the label it's connected to.

I tried putting the code into viewDidLoad in UIViewController (where the view transform is), but I can't figure out how to get it to talk to UIView.

Thanks for your help.
ggrm is offline   Reply With Quote
Old 11-21-2008, 05:23 PM   #2 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 2
Default Disable Clipping

Quote:
Originally Posted by ggrm View Post
I can put the transform code under a button in the UIView, and when I tap it, it does the transformation just fine. But that's not the automatic functionality I'm looking for.
This looks like a weird problem. Could you maybe post your code which makes the transformation work when you press a button? If it really does then my suggestion below must be wrong, but I cannot reproduce the behavior you describe.

Quote:
Originally Posted by ggrm View Post
If I put the code into awakeFromNib in UIView, it does the transform, but the slider is invisible! If I slide my finger up and down where it should be, I see the values changing in the label it's connected to.
This behavior is reproducable. The reason seems to be that the Layer moves beyond the bounds of the original frame. If I disable "Clip Subviews" in interface builder the slider stays visible. But it gets less responsive to touches.

Quote:
Originally Posted by ggrm View Post
I tried putting the code into viewDidLoad in UIViewController (where the view transform is), but I can't figure out how to get it to talk to UIView.
This sounds more like a very basic question. What good is a view controller if you can't control the view? You need to set an IBOutlet and connect it to the slider in interface builder and go from there. But how could you transform the slider without such a connection?
brassel is offline   Reply With Quote
Old 11-21-2008, 05:53 PM   #3 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 2
Default Create Slider programmatically

Quote:
Originally Posted by ggrm View Post
The app launches into landscape mode, and everything works just fine except for the slider, which I want to be vertical. I want the slider to automatically transform into vertical at the same time the app launches and goes into landscape mode.
But apart from the peculiarities of your example. What you really have to do to solve your problem is creating the slider prgrammatically. This is an example init method for the view controller which first loads your nib file and then adds the slider. All you have to do is fit in the right coordinates.

Code:
...
#import <math.h>

static inline double radians (double degrees) {return degrees * M_PI/180;}

@implementation MyViewController

- (id)init {
    if (self = [super init]) {
		self.view = [[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil] lastObject];
    }
	
	CGRect frame = CGRectMake(98,179,420,60);
	UISlider* slider = [[UISlider alloc] initWithFrame:frame];
	[slider.layer setAffineTransform:CGAffineTransformMakeRotation(radians(90))];
	[self.view addSubview:slider];

    return self;
}
brassel is offline   Reply With Quote
Old 11-24-2008, 03:30 PM   #4 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 3
Default Thanks!

You got me pointed in the right direction.

For Nick's code, I needed to put this into TwoViewAppViewController.m:
Code:
- (void)viewDidLoad {
	CGRect frame = CGRectMake(98,179,304,23);
	slider = [[UISlider alloc] initWithFrame:frame];
	
	CGAffineTransform rotation = CGAffineTransformMakeRotation(1.57079633);
	[slider setTransform:rotation];
	slider.center = CGPointMake( 468, 150 );
	
	slider.minimumValue = 1;
	slider.maximumValue = 10;
	slider.value = 5.5;
	
	[slider addTarget:self action:@selector(sliderEvent:) forControlEvents:UIControlEventValueChanged];
	
	[self.view addSubview:slider];
}

- (void)sliderEvent:(id)sender{
	...
}
ggrm is offline   Reply With Quote
Old 05-22-2009, 12:06 PM   #5 (permalink)
New Member
 
Join Date: May 2009
Posts: 2
Default Vertical UISlider sticky problem

Hi all,

I have a project to dim a light using a vertical bar. I was able to use the horizontal UISlider and rotate it. Everything work fine when I tested on the Simulator but I found out later that it didn't work well on the actual iPhone (after submitting to the app store and client complain).

I had to buy an iPhone to test it. There's a problem with slider, it works fine with horizontal bar, but when it rotates to vertical, the sensitive / easy to move the ball on the bar up and down is not good, very sticky.

Please help. I will pay for it if anyone have a solution to it. I need this asap. because my client is not happy.

Thanks a lot,
Henry
henryweb99 is offline   Reply With Quote
Reply

Bookmarks

Tags
landscape, slider, transform, vertical

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: 266
18 members and 248 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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