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 11-21-2008, 04:53 PM   #3 (permalink)
brassel
New Member
 
Join Date: Nov 2008
Posts: 2
brassel is on a distinguished road
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
 

» Advertisements
» Online Users: 377
11 members and 366 guests
alexeir, DaveDee, eski, gogoman, lionelnlex, matador1978, Pudding, roof44, sacha1996, Sami Gh, Vijithasri06
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,595
Threads: 94,084
Posts: 402,781
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Vijithasri06
Powered by vBadvanced CMPS v3.1.0

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