Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.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 08-23-2008, 09:31 AM   #51 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 84
Default

Oh and by the way, it makes it easier to understand whats going on if you switch the view mode of your interface builder xib to the tree view. Thats the 2nd icon in the group of the icons in the MainWindow.xib window in IB. Like once you have a view set to a navigation controller you can expand the tab bar controller and see the navigation bar it has added which your controller then automatically uses.
indiekiduk is offline   Reply With Quote
Old 08-23-2008, 09:56 AM   #52 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

After further reviewing this, yes, it is true, it is quite possible to do it, and even easy. (i knew both these points.

I still stick to the opinion that its better to learn how to code. And it is quite simple still..
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 02:22 PM   #53 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Chile
Age: 31
Posts: 28
Default

With al due respect... but how does this help the thread?
boliva is offline   Reply With Quote
Old 08-23-2008, 03:14 PM   #54 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 175
Default

Ok, so I have 2 tab bar items that will be simple views with no navigation. So, I created 2 xib files for them. Im trying to load them, but my app terminates when I click on the tab button and says no view was loaded. Here is the code.....

H file -
Code:
	IBOutlet MyInfoViewController *myMIViewController;
	IBOutlet AboutUsViewController *myAUViewController;

@property (nonatomic, retain) MyInfoViewController *myMIViewController;
@property (nonatomic, retain) AboutUsViewController *myAUViewController;
M file -
Code:
// Tab #2 Setup
	myMIViewController = [[MyInfoViewController alloc] initWithNibName:@"MyInfoView" bundle:nil];	
	myMIViewController.tabBarItem.image = [UIImage imageNamed:@"myinfotabbar25.png"];
		
	// Tab #3 Setup
	myAUViewController = [[AboutUsViewController alloc] initWithNibName:@"AboutUsView" bundle:nil];
	myAUViewController.tabBarItem.image = [UIImage imageNamed:@"infotabbar25.png"];

// Add ViewControllers to tab-bar
	tabBarController.viewControllers = [NSArray arrayWithObjects:
										tableNavController, myMIViewController, myAUViewController, nil];
Any ideas how to load these 2 views from XIB files? If I just alloc/init them, the app works, but of course, the view isnt loaded.
RockStrongo is offline   Reply With Quote
Old 08-23-2008, 03:17 PM   #55 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 84
Default

DevTeamOfOne, I think RockStrongo justifies my point. Something that takes 2 seconds in IB he is stuck on in code.
indiekiduk is offline   Reply With Quote
Old 08-23-2008, 03:21 PM   #56 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Lol...

Wow... you really push a point too far, don't you

I... er... conceded the point a bit earlier
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 03:26 PM   #57 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 84
Default

Well I was gonna ask him why he is trying to use code but then I thought if I wrote something that might confuse him, perhaps he will read my earlier post and give IB another go.
indiekiduk is offline   Reply With Quote
Old 08-23-2008, 03:29 PM   #58 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Quote:
Originally Posted by RockStrongo View Post
Ok, so I have 2 tab bar items that will be simple views with no navigation. So, I created 2 xib files for them. Im trying to load them, but my app terminates when I click on the tab button and says no view was loaded. Here is the code.....

H file -
Code:
	IBOutlet MyInfoViewController *myMIViewController;
	IBOutlet AboutUsViewController *myAUViewController;

@property (nonatomic, retain) MyInfoViewController *myMIViewController;
@property (nonatomic, retain) AboutUsViewController *myAUViewController;
M file -
Code:
// Tab #2 Setup
	myMIViewController = [[MyInfoViewController alloc] initWithNibName:@"MyInfoView" bundle:nil];	
	myMIViewController.tabBarItem.image = [UIImage imageNamed:@"myinfotabbar25.png"];
		
	// Tab #3 Setup
	myAUViewController = [[AboutUsViewController alloc] initWithNibName:@"AboutUsView" bundle:nil];
	myAUViewController.tabBarItem.image = [UIImage imageNamed:@"infotabbar25.png"];

// Add ViewControllers to tab-bar
	tabBarController.viewControllers = [NSArray arrayWithObjects:
										tableNavController, myMIViewController, myAUViewController, nil];
Any ideas how to load these 2 views from XIB files? If I just alloc/init them, the app works, but of course, the view isnt loaded.


Your issue is quite simple. You placed the viewController XIB's and told the interface file that it was in the MainWindow.xib file, which it clearly is not.

Remove the IBOutlet off of the interface bits

Last edited by DevTeamOfOne; 08-23-2008 at 03:33 PM.
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 03:30 PM   #59 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Quote:
Originally Posted by indiekiduk View Post
Well I was gonna ask him why he is trying to use code but then I thought if I wrote something that might confuse him, perhaps he will read my earlier post and give IB another go.
That might have something to do with the fact that he is using separate XIB files
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 03:32 PM   #60 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 175
Default

Quote:
Originally Posted by DevTeamOfOne View Post
Your issue is quite simple. You haven't added the controllers correctly. Why are you doing your initialization of the tabBarItems in the App delegate? Do it in your tableViews.

Next... You haven't added any navigation Controllers. If you didn't want to have them, then just add the controller as you have without the tabbar item info.

If you add the navigation controller, follow the guide i placed on page 1.
Thanks! Ill give this a shot.

I do have a nav controller for tab 1. I just didnt post it. Its working fine.
RockStrongo is offline   Reply With Quote
Old 08-23-2008, 03:50 PM   #61 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

review my post
I have updated it after I saw that you were initializing from separate XIB files.
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 03:52 PM   #62 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 175
Default

Quote:
Originally Posted by indiekiduk View Post
DevTeamOfOne, I think RockStrongo justifies my point. Something that takes 2 seconds in IB he is stuck on in code.
Well, I really want to understand the code too. Using Dev's suggestions in this thread, I created a skeleton for my app and its working.

After getting this down, I wanted to use XIB files for these 2 simple views.

They are more visual in nature, so I wanted to see them in interface builder and play around with them there. I would not have used IB for the whole project.

In the long run, I think learning this programmatically will be more beneficial. Just my opinion.
RockStrongo is offline   Reply With Quote
Old 08-23-2008, 03:56 PM   #63 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

indiekiduk... this was where my point lied.

If RockStrongo doesn't understand the concepts here, then there will be major reprecussions for the rest of his app building. The concepts of Cocoa Touch and objective-C are understood perfectly by a good understanding of what is going on between a Tab Bar, a Navigation Bar and a Table View.

By cheating with IB, RockStrongo will lose the opportunity to learn how to do these simple Objective-C procedures.
DevTeamOfOne is offline   Reply With Quote
Old 08-23-2008, 05:28 PM   #64 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 175
Default

Quote:
Originally Posted by DevTeamOfOne View Post
YYou placed the viewController XIB's and told the interface file that it was in the MainWindow.xib file, which it clearly is not.

Remove the IBOutlet off of the interface bits
Hey Dev...ok, so what did you mean by saying the interface file thinks its in the MainWindow.xib?

When I remove the IBOutlet's, it still performs the same.

How is MainView.xib associated with the app delegate? If I understand that, it might help out.
RockStrongo is offline   Reply With Quote
Old 08-25-2008, 10:48 AM   #65 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 10
Default

DevTeamOfOne,

Your code to create a tab controller with navigation controllers within it works great! I have one question. I have a tab bar controller where one of my tabs (not the initial view) is a UIWebView.

How can I have the webView load a URL without having to activate its tab and click a button. Do you know how I can load the request from the appDelegate?

You're the man.
vosens is offline   Reply With Quote
Old 08-27-2008, 11:23 AM   #66 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 3
Default

@indiekiduk
Do you now of a video that shows how to do this via IB? Like everyone else on this thread I am very new to IB and to me there is a steep learning curve. When you say "Click the status bar of the tab bar controller icon in IB" I don't know what you mean along with everything else you say in your comment #50.

What I am trying to do is start with a Nav template and then add a Tab Bar. Both view needs will have a TableView in them.
james.lorenzen is offline   Reply With Quote
Old 08-27-2008, 11:43 AM   #67 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 84
Default

You need to start with a Tab bar application. Then you add navigation controllers into each tab view.
indiekiduk is offline   Reply With Quote
Old 08-27-2008, 12:37 PM   #68 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 84
Default

Ok I have made you a quicktime video, sorry no audio.

Tab Bar Demo
In this app I have a Tab Application with 2 tabs. Both tab views are set to Navigation Controllers - that is why you see a navigation bar in both tabs. The first view in each navigation controller is set to load from seperate XIBs. Both FirstView.xib and SecondView.xib are UITableViewControllers. I created 2 UITableViewController subclasses which each xib's File Owner class are set to (That is the blue square).

Extra notes:
1. I had to delete the SecondViewController.m and .h files because they were subclasses of UIViewController and not UITableViewController. I could have changed the code but if you use the class wizard you get all of the table methods in the file when it is created.
2. I had to add the CoreGraphics framework because it would have failed to link the CGRectZero symbol which is needed to build. Apple should have included this by default.
3. Oops I didn't really need to delete the original SecondView.xib I could have just edited it.

Download it here.

Last edited by indiekiduk; 08-27-2008 at 12:52 PM.
indiekiduk is offline   Reply With Quote
Old 08-27-2008, 01:22 PM   #69 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Quote:
Originally Posted by RockStrongo View Post
Hey Dev...ok, so what did you mean by saying the interface file thinks its in the MainWindow.xib?

When I remove the IBOutlet's, it still performs the same.

How is MainView.xib associated with the app delegate? If I understand that, it might help out.
MainWindow.xib is tied at the base level with your app delegate through the info.plist file.

When you call IBOutlet in any interface file, you are saying: When my app launches, this section is shown in the IB file it launched with. In this case, MainWindow.xib.

What you need to do: call it as a property, that is, take out the IBOutlet bit, and also add in the @property bit.

Then Synthesize it into your app in the implementation file.

Then say

whateverItIs = [[WhateverItIs alloc] initWithNibFile:whateverItIs bundle:nil]; in the appDidFinishLaunching bit.

that creates a property that holds through the entire app. That property you have said, is a class of WhateverItIs, and you are telling the compiler to initiate it by activating the XIB file in no bundle.

Make sure you release this property at dealloc.
DevTeamOfOne is offline   Reply With Quote
Old 08-27-2008, 01:31 PM   #70 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Quote:
Originally Posted by vosens View Post
DevTeamOfOne,

Your code to create a tab controller with navigation controllers within it works great! I have one question. I have a tab bar controller where one of my tabs (not the initial view) is a UIWebView.

How can I have the webView load a URL without having to activate its tab and click a button. Do you know how I can load the request from the appDelegate?

You're the man.

Well, This may seem like a simplistic way... send it a message

[[yourWebViewController webView] loadRequestNSURLRequest *)request];

simple? Just put this in the App Delegate when you want to load the page

Make sure that your UIWebView is a property of your viewcontroller first

Make sure you make yourviewcontroller a persistent property only released at dealloc if you want to load the url at any time.

Last edited by DevTeamOfOne; 08-27-2008 at 01:33 PM.
DevTeamOfOne is offline   Reply With Quote
Old 09-02-2008, 03:13 AM   #71 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 13
Default

Hi Boston,
Can you share your code with me?? I need example code to understand TabBar application
dhanasekar is offline   Reply With Quote
Old 09-02-2008, 04:45 AM   #72 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

This thread, particularly the first page, should be very helpful for that. Any other questions, you can ask me.
DevTeamOfOne is offline   Reply With Quote
Old 09-02-2008, 04:53 AM   #73 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 13
Default

I have a three tab views, in the first tab i need to show web view then in the second tab i need to show table view and third tab i need to show couple of text and label with one button(like user login screen). I can able to develop UI. first tab view i added UIWebView then second tab i added UITableView then third tab i added simply UIView. How do i create corresponding .h and .m file to display google page on first tab, list of names on table view and login ??????
dhanasekar is offline   Reply With Quote
Old 09-02-2008, 05:44 AM   #74 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

If you'd like to send your project to my email address send it to sonofstrength@hotmail.com, and I should be able to help you better. I am finding it a little difficult to see what you mean, but the code should make this clearer
DevTeamOfOne is offline   Reply With Quote
Old 09-04-2008, 06:41 PM   #75 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 14
Default

Hi guys,

dev your code helped me a lot. one question, however: how do i add icons for the view controllers that i added to the tabBarController? I've been stuck on that for a while.

thanks!
ddlingling 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: 263
18 members and 245 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, prchn4christ, Rudy, Speed
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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