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 09-12-2011, 05:14 PM   #1 (permalink)
Rock On!
 
dana0550's Avatar
 
Join Date: Apr 2011
Location: U.S.A.
Posts: 89
dana0550 is on a distinguished road
Default Question about adding view from an XIB file.

Hello Everyone,

I am not really sure where to start with this and I would like to fully understand what I am doing so that is why I am turning to you guys and girls.

I have a main view in an application, in this view there are 2 views embedded within the parent view. To paint a clearer picture the 2 embedded views are 300x200.

Now my question is how do I add an XIB file into one of the views. The reason why I am asking this is because the top view is a table view. I do not want the main window of the project to be of UITableView class. I would like it to remain of UIView.

Therefore I am attempting to reference the TableView.xib into the small view in the main view.

If I am approaching this the wrong way please feel free to let me know, if this is doable then what is the best way?

I though of using addSubview, but it is not a subview that I am am trying to add. I need to add an xib to the view.

Any advice is appreciated.
Dana

P.S. I did not add code yet because I am just starting this app.
__________________
Appadana Development
dana0550 is offline   Reply With Quote
Old 09-12-2011, 06:11 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by dana0550 View Post
Hello Everyone,

I am not really sure where to start with this and I would like to fully understand what I am doing so that is why I am turning to you guys and girls.

I have a main view in an application, in this view there are 2 views embedded within the parent view. To paint a clearer picture the 2 embedded views are 300x200.

Now my question is how do I add an XIB file into one of the views. The reason why I am asking this is because the top view is a table view. I do not want the main window of the project to be of UITableView class. I would like it to remain of UIView.

Therefore I am attempting to reference the TableView.xib into the small view in the main view.

If I am approaching this the wrong way please feel free to let me know, if this is doable then what is the best way?

I though of using addSubview, but it is not a subview that I am am trying to add. I need to add an xib to the view.

Any advice is appreciated.
Dana

P.S. I did not add code yet because I am just starting this app.

It does sound like you are going about this the wrong way.

A typical iOS app has one or more view controllers (UIViewController objects)

A view controller maintains an entire screen. It has a "main" view that is the size of the whole screen, and then some number of subviews that contain things like table views, buttons, image views, etc.

To add a table view to a view controller, you would drag a table view object into the view controller's main view in interface builder. You can size it to take up the whole screen, or just part of then screen. You'd then add the buttons and other views that would make up the window.

Views are arranged in a hierarchy. Views contain other views, which in turn can contain other views. It is possible to add a view and it's subiviews to a window's existing set of views by loading it from a nibfile, but that's unusual, and fairly advanced. If you're just starting out, you're almost certainly on the wrong track if you're wanting to do that. Start out by building your view controller's views using a nib file in interface builder.
__________________
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.
Duncan C is offline   Reply With Quote
Old 09-12-2011, 06:17 PM   #3 (permalink)
Rock On!
 
dana0550's Avatar
 
Join Date: Apr 2011
Location: U.S.A.
Posts: 89
dana0550 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
It does sound like you are going about this the wrong way.

A typical iOS app has one or more view controllers (UIViewController objects)

A view controller maintains an entire screen. It has a "main" view that is the size of the whole screen, and then some number of subviews that contain things like table views, buttons, image views, etc.

To add a table view to a view controller, you would drag a table view object into the view controller's main view in interface builder. You can size it to take up the whole screen, or just part of then screen. You'd then add the buttons and other views that would make up the window.

Views are arranged in a hierarchy. Views contain other views, which in turn can contain other views. It is possible to add a view and it's subiviews to a window's existing set of views by loading it from a nibfile, but that's unusual, and fairly advanced. If you're just starting out, you're almost certainly on the wrong track if you're wanting to do that. Start out by building your view controller's views using a nib file in interface builder.
Duncan,

Thanks for your response. I definitely was going about it the wrong way, I was not too sure what I was thinking but shortly after posting this I realized there is not need to embed the table view within a view and load the table from another nib. I just added the table view to the UIViewController Class and added the Table Source delegate and datasource.

I am no pro by any means but not a total beginner. Sorry for the crazy post. I am not sure what I was thinking. I was making it way more complicated than it had to be. So either way I should be on the right track now. We will see...

Dana
__________________
Appadana Development
dana0550 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
9 members and 392 guests
7twenty7, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

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