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 > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 02-25-2011, 10:54 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 17
CrystalBlue is on a distinguished road
Default Better way of creating a custom interface?

I'm deep in trying to create a fully customized layout for an application that I'm working on. What I'm doing is creating sub-classes of labels, views, and buttons and placing those into the main application class, which will hold the whole of my application.

I guess my problem is, it seems to be a lot of calculating the position, size, and orientation of the views and buttons I place. It seems simple enough to just give a control an X-Y position and a width-height size and let it go, but when I have to worry about portrait orientation versus landscape orientation, and how I have to calculate, store, and recall a different frame for every view and button I do simply because I cannot set the size and position to be something different...it starts to become a mired headache. Add to this fact that I have a lot of views and such that are dependent on each other for their sizes. Such that a header view has two buttons to the left and right of it and if the header's size changes, the buttons need to dynamically change with it...

I guess I'm starting to get lost and I need to know if this is really the best and true way to make a completely custom interface. Holding a store of CGRects in each view just to tell it what to do when the iPad flips seems redundant. Or is it that all of the work I'm doing placing and setting actions to fire when the orientation of the screen changes something that IB is supposed to be doing and by creating my own custom interface, I'm having to do the work instead?
CrystalBlue is offline   Reply With Quote
Old 10-20-2011, 10:55 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 113
jonusx is on a distinguished road
Default

Look into making a custom container view. Then you can swap out views and have all the callbacks work properly. Check out my custom interface in Oneshare
__________________
What do you have to share? Share and view pics Oneshare

Play Magic: The Gathering? Try The Sylvan Archives!

Warhammer 40k your thing? W40k Manager is your thing.

Like karaoke? Try iSing Karaoke Locator
jonusx is offline   Reply With Quote
Old 10-30-2011, 08:46 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,002
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by CrystalBlue View Post
I'm deep in trying to create a fully customized layout for an application that I'm working on. What I'm doing is creating sub-classes of labels, views, and buttons and placing those into the main application class, which will hold the whole of my application.

I guess my problem is, it seems to be a lot of calculating the position, size, and orientation of the views and buttons I place. It seems simple enough to just give a control an X-Y position and a width-height size and let it go, but when I have to worry about portrait orientation versus landscape orientation, and how I have to calculate, store, and recall a different frame for every view and button I do simply because I cannot set the size and position to be something different...it starts to become a mired headache. Add to this fact that I have a lot of views and such that are dependent on each other for their sizes. Such that a header view has two buttons to the left and right of it and if the header's size changes, the buttons need to dynamically change with it...

I guess I'm starting to get lost and I need to know if this is really the best and true way to make a completely custom interface. Holding a store of CGRects in each view just to tell it what to do when the iPad flips seems redundant. Or is it that all of the work I'm doing placing and setting actions to fire when the orientation of the screen changes something that IB is supposed to be doing and by creating my own custom interface, I'm having to do the work instead?

You can use IB to manage custom objects. I do that all the time.

Just drag UIViews, labels, buttons, etc. onto your screen design. Use container views to group other views like a header with buttons on either side. Learn how to use the IB "struts and springs" to get your views resizing the way you want.

Once you get your layout the way you want it, and resizing the way you want it, select the objects and change their class to your custom classes. IB will still manage them, since they should be subclasses of UIView/UIButton/UILabel, whatever.

It's much, much easier to manage layout and orientation changes in IB than it is in custom code. As you're learning, controlling all that stuff in code is a huge amount of work.

You may have to add some custom code to adjust the rotation behavior or some of your view groups, but you should be able to get really close with clever use of grouping and "struts and springs" controls.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.

Last edited by Duncan C; 10-30-2011 at 08:57 PM.
Duncan C is online now   Reply With Quote
Old 11-23-2011, 05:31 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
You can use IB to manage custom objects. I do that all the time.

Just drag UIViews, labels, buttons, etc. onto your screen design. Use container views to group other views like a header with buttons on either side. Learn how to use the IB "struts and springs" to get your views resizing the way you want.

Once you get your layout the way you want it, and resizing the way you want it, select the objects and change their class to your custom classes. IB will still manage them, since they should be subclasses of UIView/UIButton/UILabel, whatever.

It's much, much easier to manage layout and orientation changes in IB than it is in custom code. As you're learning, controlling all that stuff in code is a huge amount of work.

You may have to add some custom code to adjust the rotation behavior or some of your view groups, but you should be able to get really close with clever use of grouping and "struts and springs" controls.
I'm really hoping the auto layout will make its way from the Cocoa side into Cocoa Touch as well, it looks so awesome. Things like these would be a lot simpler with it. Perhaps we should all file bug reports requesting it?
fiftysixty is offline   Reply With Quote
Old 11-24-2011, 09:55 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2011
Location: California
Posts: 225
KarlJay is on a distinguished road
Default

You mentioned: "Or is it that all of the work I'm doing placing and setting actions to fire when the orientation of the screen changes something that IB is supposed to be doing and by creating my own custom interface, I'm having to do the work instead?"

I don't think IB does that for you. I think the Object does that for itself. I could be wrong here, I'm trying to learn to develop without IB. I'd rather do things in code.
But, my understanding of IB is that it's just a screen layout tool. After you layout your screen, you make all the connections and it's very easy to see what the screen will look like and to make changes.

But I don't think IB has anything to do with changing position when you rotate the screen.

If your using stock objects, isn't there settings for how the object behaves when the screen is rotated?
KarlJay 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: 401
18 members and 383 guests
Brandt, coolman, Domele, Duncan C, fredidf, Free App Monster, givensur, iAppDeveloper, jbro, locombiano89, Mah6447, Meoz, simplymuzik3, SLIC, stanny, stevenkik, Tomsky, WeaselPig
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,863
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

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