Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Yeah, I will eventually get to that, first I want my toolbar to work properly.... I am on day 2 of trying to figure this out, it is about to be day 3 pretty soon... pretty pathetic that its going to take me days to figure out a damn toolbar.... I am so embarrassed and upset by this you have no idea.... I have been reading so many books and tutorials that my eyes are practically bleeding!
 
Maybe you should explain you needs/justifications for the tab-bar and the navigation controllers.

For example, these lines from your code confuse me:
Code:
[window addSubview:tabBarController.view];
[window addSubview:navigationController.view];
 
Mokay, I did it. (Sorry Dejo)

Word of advice: This is beginner stuff. If you really want to learn this you can't learn it on this forum. You need to do it the old fashioned way. Get a book, take a class. Otherwise, pay some one to do it for you.
 

Attachments

  • TheSalesHuddle.zip
    263.7 KB · Views: 84
I have the tabbar so I can move from view to view. I have the navigation bar so I can put the titles on the navigation bar at the top of each view as you can see in the pictures.... should I remove something? I have done this whole app over about a months time so to be really honest it is hard to say why certain things are the way they are. I basically learned from a few books and this is how they taught me.... very sad, I am sorry.... should I just forget this app and try again? I am on several boards and no one can help, everyone is confused about why I did certain things and it is starting to confuse me too....

EDIT:

I have so many books it is not even funny.... i don't know this is crazy..... I don't understand how I made it this far only to fail.... the more I read books the more i get confused because everyone has their own way of doing things.... also none of the practice applications ever teach me anything I want to know... I made so many damn tip calculators and lists and all types of stuff but no tutorials on webviews with a toolbar except for having a search bar but I don't need a search bar.... or they have toolbars that add and subtract numbers and stuff but I don't see how it translates to what I am doing .....
 
Last edited by a moderator:
It'll take longer to explain than it did to do it.

I downloaded the source.
For some strange reason there was no WebViewController.xib file in there even though all the code was in that view controller.
I copied one of the other copies that looked like it was supposed to be the WebViewController.xib file and added in the toolbar in IB.
Commented out all the code that built the toolbar.
Added a single action method "whatever" and hooked up the single toolbar button to this action method.
Adjusted the struts for the toolbar and the webview so they don't cover each other.
Build and Run.

Is that the goal of this exercise?
 

Attachments

  • Huddle.jpg
    Huddle.jpg
    58.7 KB · Views: 108
Last edited:
Yes, this UI is different than the usual one. You don't usually have a toolbar on the top like this on iPhone so I guess there might not be any examples exactly like this.

So does the uploaded project do what you want?
 
The way your code is set up you call alloc/init for your view controllers but you don't ever specify the name of the nib file. That works if the nib file is the same name as the view controller. Otherwise there's no way for the base class to know which nib to load.
 
I have the tabbar so I can move from view to view. I have the navigation bar so I can put the titles on the navigation bar at the top of each view as you can see in the pictures.... should I remove something?
Ah, I think I understand what you're trying to do now. So, you can probably remove this line:
Code:
[window addSubview:navigationController.view];
I don't think it serves any purpose.

Also, you can remove webNavController. It's not really used for anything.
 
ok, let me take this all in I am going to go through this again.....

Do I need to change BlogViewController.xib to WebViewController.xib?

EDIT:

No I def will look at it, I just don't see an archive I just see the image of the Simulator which looks exactly how I want....
 
Last edited by a moderator:
OKAY!!! I see it now let me look through this archive and see what I did wrong... thank you guys so much you have no idea i have been beating myself up over this....
 
@primedime, well post back when you've gone over it and also post over in the apple forum so Rufus doesn't look at your app when his show is over.
 
I don't usually depend on the behavior of the base class to load a nib that has the same name as the class, like you're doing in this code. Since you already have an override of initWithNibName you can just add the correct nib name on the line that calls super initWithNibName. Then your nib can have whatever name you like.
 
Here is the final code used.... thanks again guys, i cant say it enough!


Code:
//  WebViewController.h
//  TheSalesHuddle

#import <UIKit/UIKit.h>

@interface WebViewController : UIViewController <UIWebViewDelegate>
{
	UIWebView *myWebView;
	UIActivityIndicatorView *spinnerView;
	UIToolbar *toolbar;
}

@property (nonatomic, retain) IBOutlet UIWebView *myWebView;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinnerView;
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;

-(IBAction)stopLoading;
-(IBAction)reload;
-(IBAction)goBack;
-(IBAction)goForward;

@end

Code:
//  WebViewController.m
//  TheSalesHuddle
//
//  Created by Roy Jossfolk Jr on 2/24/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "WebViewController.h"

@implementation WebViewController

@synthesize myWebView;
@synthesize spinnerView;
@synthesize toolbar;

- (void)loadWebPageWithString:(NSString *)urlString
{
	NSURL *url = [NSURL URLWithString:urlString];
	NSURLRequest *request = [NSURLRequest requestWithURL:url];
	[myWebView loadRequest:request];
}

//Tab Bar Image and title
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
	if ((self = [super initWithNibName:nibName bundle:bundle]))
	{
		UIImage *tabImage = [UIImage imageNamed:@"blogIcon.png"];
		UITabBarItem *tabBarItem = [[UITabBarItem alloc]
									initWithTitle:@"BLOG"
									image:tabImage
									tag:0];
		self.tabBarItem = tabBarItem;
		[tabBarItem release];
	}
	return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
	[myWebView stopLoading];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
	
	[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://thesaleshuddle.com"]]];
}

-(IBAction)stopLoading
{
	NSLog(@"stopLoading");
}
-(IBAction)reload
{
	NSLog(@"reload");
}
-(IBAction)goBack
{
	NSLog(@"goBack");
}
-(IBAction)goForward
{
	NSLog(@"goForward");
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

}

// release
- (void)dealloc {
	
	[myWebView release];
	[spinnerView release];
    [super dealloc];
}

#pragma mark -
#pragma mark UIWebViewDelegate methods

- (void)webViewDidStartLoad:(UIWebView *)myWebView
{
	[spinnerView startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)myWebView
{
	[spinnerView stopAnimating];
}

@end


Final Image:
 

Attachments

  • Screen shot 2011-03-21 at 9.25.32 PM.png
    Screen shot 2011-03-21 at 9.25.32 PM.png
    219.5 KB · Views: 102
I don't usually depend on the behavior of the base class to load a nib that has the same name as the class, like you're doing in this code. Since you already have an override of initWithNibName you can just add the correct nib name on the line that calls super initWithNibName. Then your nib can have whatever name you like.

Ah, so the "quick" fix (OP would still need to add the toolbar and hook up the buttons) would be to simply change the WebViewController instantiation line in the appDelegate to:
Code:
WebViewController *webViewController = [[WebViewController alloc]
    initWithNibName:@"BlogViewController"
    bundle:[NSBundle mainBundle]];
 
Yes the nib name could be specified there or in the "final" code that he showed he could put it in the initWithNibName method, as I mentioned.

Code:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
	if ((self = [super initWithNibName:@"BlogViewController" bundle:nil]))

I prefer to put the nib name in the view controller's init or initWithNibName method.
 
Yes the nib name could be specified there or in the "final" code that he showed he could put it in the initWithNibName method, as I mentioned.

Code:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
	if ((self = [super initWithNibName:@"BlogViewController" bundle:nil]))

I prefer to put the nib name in the view controller's init or initWithNibName method.
Ah. Thanks for the explanation, Phoney. See even a "pro" like myself can still find things to learn (or be reminded of having forgotten).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.