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 02-19-2011, 10:00 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 4
bugphix is on a distinguished road
Default Editing a UIView which was created via code in IB

Hi,
I have an application which has a tabbar in it.
once the user clicks lets say 3rd tab item, it loads the thirdViewController and thirdView.xib.
I opened this xib file in interface builder and put inside a UIView and called it a subViewsContainer.
Also connected this with an IBOutlet of the same type in my thirdViewController.
In my controllers interface (.h) I created 2 different views which will be added as a subview to my container view when the user presses on 2 different buttons in this view.
Each time a user presses button1 I remove all subviews of my container, alloc and init my 1st subview and add it to my container and release my 1st subview.
the same goes for button2 and my 2nd subview..

Now my question is:
Since I created these 2 subviews in my thirdViewController, they dont have any xib. But now i want to add visual elements via interface builder. But cannot.. (since they don't have xibs or an m or h files of their own..)

Is there a way I can design and add items to the subviews I created using code in interfacebuilder?

Thank you
bugphix is offline   Reply With Quote
Old 02-19-2011, 10:54 AM   #2 (permalink)
Crafty Veteran
 
Magic Hands's Avatar
 
Join Date: Nov 2008
Location: Memphis, TN
Age: 23
Posts: 436
Magic Hands is on a distinguished road
Send a message via Skype™ to Magic Hands
Default

Quote:
Originally Posted by bugphix View Post
Hi,
I have an application which has a tabbar in it.
once the user clicks lets say 3rd tab item, it loads the thirdViewController and thirdView.xib.
I opened this xib file in interface builder and put inside a UIView and called it a subViewsContainer.
Also connected this with an IBOutlet of the same type in my thirdViewController.
In my controllers interface (.h) I created 2 different views which will be added as a subview to my container view when the user presses on 2 different buttons in this view.
Each time a user presses button1 I remove all subviews of my container, alloc and init my 1st subview and add it to my container and release my 1st subview.
the same goes for button2 and my 2nd subview..

Now my question is:
Since I created these 2 subviews in my thirdViewController, they dont have any xib. But now i want to add visual elements via interface builder. But cannot.. (since they don't have xibs or an m or h files of their own..)

Is there a way I can design and add items to the subviews I created using code in interfacebuilder?

Thank you
Declare your views in .h as "IBOutlet UIView *yourViewName" and then add a view in IB then connect them.
__________________
Magic Hands is offline   Reply With Quote
Old 02-19-2011, 11:18 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 4
bugphix is on a distinguished road
Default

Quote:
Originally Posted by Magic Hands View Post
Declare your views in .h as "IBOutlet UIView *yourViewName" and then add a view in IB then connect them.
Thank you,
but now i cannot add subview and release it right?
because since i added views from the interface builder now they are already allocated and initialized?

in order to switch between views using my buttonsi have to use hidden = yes or no then?

Thanks again
bugphix is offline   Reply With Quote
Old 02-19-2011, 11:33 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 4
bugphix is on a distinguished road
Default

Quote:
Originally Posted by Magic Hands View Post
Declare your views in .h as "IBOutlet UIView *yourViewName" and then add a view in IB then connect them.
Great, it works (using hidden yes and no)
Now one last question:

Is there a way to see the views i created in IB seperately?
I'm trying to edit my 1st subview in IB but the 2nd is on my way :/
bugphix is offline   Reply With Quote
Old 02-19-2011, 11:58 AM   #5 (permalink)
iOS / MacOS Developer
 
bharath2020's Avatar
 
Join Date: Oct 2008
Location: Bengaluru
Posts: 151
bharath2020 is on a distinguished road
Default

Setting the view's background color is one way to test the view i your xib.. if u are not seeing the particular view in the app, then you can set reduce its alpha value of just hide it..
__________________
Bharath
iOS Blog : http://iphone2020.wordpress.com
bharath2020 is offline   Reply With Quote
Old 02-19-2011, 12:08 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 4
bugphix is on a distinguished road
Default

Quote:
Originally Posted by bharath2020 View Post
Setting the view's background color is one way to test the view i your xib.. if u are not seeing the particular view in the app, then you can set reduce its alpha value of just hide it..
hi bharath,
i already see that the views work fine when i run my app.
i now want to add stuff to each view through IB and my problem is not while the app is running but during the editing process in Interface Builder where I created a label for instance and dragged it under the 1st subview, but when i want to move it around, i'm trying to drag it by holding it, but the interface builder thinks i want to drag the 2nd subview.
(oh did i mention that these 2 subviews overlap )
so it's hard to edit them :/
i wonder if anyone could understand anything from my way of telling it
bugphix is offline   Reply With Quote
Old 02-19-2011, 07:33 PM   #7 (permalink)
iOS / MacOS Developer
 
bharath2020's Avatar
 
Join Date: Oct 2008
Location: Bengaluru
Posts: 151
bharath2020 is on a distinguished road
Default

Gotcha.. its very simple..

In interface builder, there is a window which displays your Fule owner, view and other objects.. In e same window youndo hace option to view the View hierarchy in a tree view, Browser view ( simi,ar to how you see Files i filnder)..

these options will help you to ick a particular component at will..

( i just have an ipaf now, otherwise i could got you a snaoshot)

Hope this answers..
__________________
Bharath
iOS Blog : http://iphone2020.wordpress.com
bharath2020 is offline   Reply With Quote
Reply

Bookmarks

Tags
controller, interface builder, subview, uiview, view

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
14 members and 364 guests
cpsclicker, dre, Error404, Gaz, gmarro, jeroenkeij, Kirkout, mottdog, Music Man, PavelMik, teebee74, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

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