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 12-11-2008, 05:18 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Default Location of UI Objects on my view?!?!?!?!

I added an item to my UIView using code.
How can i set the location of this object using code?

Thank You
aryaxt is offline   Reply With Quote
Old 12-11-2008, 05:45 PM   #2 (permalink)
1026 Development
 
Join Date: Jul 2008
Age: 23
Posts: 1,094
Jeremy1026 is on a distinguished road
Send a message via AIM to Jeremy1026
Default

Quote:
Originally Posted by aryaxt View Post
I added an item to my UIView using code.
How can i set the location of this object using code?

Thank You
To add an item in code you use the following code.

Code:
		CGRect settingsBarRect = CGRectMake(0.0,460.0,320.0,20.0);
		settingsButton = [UIButton buttonWithType:UIButtonTypeCustom];
		[settingsButton setTitle:@"Settings" forState:UIControlStateNormal];
		[settingsButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
		[settingsButton setFrame:settingsBarRect];
		[settingsButton addTarget:self action:@selector(gotoSettings) forControlEvents:UIControlEventTouchUpInside];
		[self.view addSubview:settingsButton];
That would create a custom button with the text "Settings" at the bottom of the screen.
Jeremy1026 is offline   Reply With Quote
Old 12-11-2008, 05:56 PM   #3 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
RickMaddy will become famous soon enough
Default

Every UIView based class has the properties 'frame', 'bounds', and 'center'.

Read through the docs for UIView. This is a class you will use A LOT. It's good to get to know what it can do.
RickMaddy is offline   Reply With Quote
Old 12-11-2008, 05:56 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Default

Thanks A lot. Lots of great answers in this forum.
Just 1 problem here. The item that I am trying to add to this view is another UIView, which is already created using interface builder.
I use the code below to add this view to my main view. everything runs fine and compiles well except the new view that i added to my main view does not show up on the screen. That's why i thought it might be the location of the view.
Any suggestions?


- (void)loadView {
Seat *s = [[Seat alloc]
initWithNibName:@"Seat" bundle:[NSBundle mainBundle]];
[self.view addSubview:s.view];
[self.view bringSubviewToFront:s.view];
}
aryaxt is offline   Reply With Quote
Reply

Bookmarks

Tags
location, uiview

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: 378
12 members and 366 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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