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 01-24-2011, 01:43 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default Tab Bar & Reloading UIWebViews

Hey Guys,

I'm having a bit of an issue trying to figure out what the proper method is to refresh a a UIWebView when it is one of the Tabs on my Tab Bar (the reason why I suspect this is important to denote is because the view is not getting pushed).

I've got a few tabs, and a tab bar controller all nicely set up.
In 2 of the tabs I have 2 corresponding ViewControllers with WebViews done in in IB, everything is hooked up and works fine.

What I'd like to happen is whenever they flip back and forth between tabs, is for the page to be reloaded whenever that tab is selected.

So I did this...
I created the
Code:
- (void)viewWillAppear:(BOOL)animated
{
	[super viewWillAppear:(BOOL)animated];
	[busSchedule reload];
}
and invoked the reload method on the WebView, unfortunately...no dice.
I've also tried a variety of other methods with no luck either.

The UIWebView is loaded in viewDidLoad as such...
Code:
- (void)viewDidLoad 
{
	[super viewDidLoad];
	
	NSString *urlAddress = @"http://assets.strose.edu/mobileweb/shuttleschedule/default.aspx";
	NSURL *url = [NSURL URLWithString:urlAddress];
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
	[busSchedule loadRequest:requestObj];
}
So I the question is, how exactly do I get this behavior to happen?

Thanks,
Justin

Last edited by n2pb; 03-20-2011 at 03:37 AM.
n2pb is offline   Reply With Quote
Old 01-26-2011, 11:06 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

Bump.
Anything guys?
n2pb is offline   Reply With Quote
Old 01-26-2011, 11:47 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 79
xqtr is on a distinguished road
Default

Quote:
Originally Posted by n2pb View Post
Bump.
Anything guys?
webView.h:
Code:
@interface webView : UIViewController {
	IBOutlet UIWebView * busSchedule;
}
webView.m:
Code:
@synthesize webview;

- (void)viewDidAppear:(BOOL)animated{
	[super viewDidAppear:animated];
	[busSchedule reload];
}
This worked for me
xqtr is offline   Reply With Quote
Old 01-26-2011, 01:58 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

For some reason [busShedule reload]; doesn't work.
That being said I did recreate the NSURLRequest and throw it in the viewDidAppear, and it properly worked, despite that the reload method didn't.

Thanks!
n2pb is offline   Reply With Quote
Old 01-26-2011, 02:02 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 79
xqtr is on a distinguished road
Default

Quote:
Originally Posted by n2pb View Post
For some reason [busShedule reload]; doesn't work.
That being said I did recreate the NSURLRequest and throw it in the viewDidAppear, and it properly worked, despite that the reload method didn't.

Thanks!
This is how my viewDidLoad looks like:
Code:
- (void)viewDidLoad {
	[super viewDidLoad];
	NSString *address = @"http://assets.strose.edu/mobileweb/shuttleschedule/default.aspx";
	NSURL *url = [NSURL URLWithString:address];
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
	[self.busSchedule loadRequest:requestObj];
}
xqtr is offline   Reply With Quote
Old 01-26-2011, 05:23 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

If I throw exactly what you have in viewDidLoad (actually I can remove viewDidLoad entirely because it seems that viewDidAppear is also being called simultaneous to viewDidLoad), but instead put it in viewDidAppear, it works PERFECTLY.

I'm still curious why I can't get the page to refresh by doing it the way you have using just the reload method in the viewDidAppear. But I'm just happy enough to have it working! I'm not really sure why I never thought of doing it that way, I just figured it was "proper" to use the reload method in viewDidAppear.
n2pb is offline   Reply With Quote
Reply

Bookmarks

Tags
reload, tab bar, uiwebview

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: 366
12 members and 354 guests
7twenty7, Clouds, dre, EvilElf, iAppDeveloper, jeroenkeij, Mah6447, Morrisone, sacha1996, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,899
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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