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-20-2010, 08:52 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Location: Netherlands
Posts: 28
TwanB is on a distinguished road
Default didFailLoadWithError shows alert when MP3 is loaded

In my WebView app I have this code for network connection check:

Code:
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
	UIAlertView *connectionAlert = [[UIAlertView alloc] initWithTitle:@"Connection Failed" 
															  message:[NSString stringWithFormat:@"Make sure your device is connected to the internet and try again.",[error localizedDescription]] 
															 delegate:self 
													cancelButtonTitle:@"Close" 
													otherButtonTitles: nil];
	
	[connectionAlert show];
	[connectionAlert release];
	
}
I have links in the html-page to MP3's. When I click those, the AlertView is displayed. How can I fix this?

Thanks for your help?

Last edited by TwanB; 03-07-2010 at 03:36 AM. Reason: unanswered still
TwanB is offline   Reply With Quote
Old 06-21-2010, 05:06 AM   #2 (permalink)
LHT
Registered Member
 
Join Date: Jun 2010
Posts: 7
LHT is on a distinguished road
Default

I encountered the exact same problem. Did you find a solution?
LHT is offline   Reply With Quote
Old 06-21-2010, 01:41 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Location: Netherlands
Posts: 28
TwanB is on a distinguished road
Default

Quote:
Originally Posted by LHT View Post
I encountered the exact same problem. Did you find a solution?
Unfortunately I haven't. If you find a solution, please keep me posted. I'll do the same for you.
TwanB is offline   Reply With Quote
Old 06-21-2010, 02:14 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

You haven't checked or NSLog'd the NSError object passed to you, it must have the reason of the error. Then you need to check wether the error is related to internet connectivity or not.
nobre84 is offline   Reply With Quote
Old 06-22-2010, 05:47 AM   #5 (permalink)
LHT
Registered Member
 
Join Date: Jun 2010
Posts: 7
LHT is on a distinguished road
Default

Well for me it's working now. Here is the code:

Code:
- (void)viewDidLoad {
	NSURL *url = [NSURL URLWithString:@"http://url.com"];
	NSURLRequest *request = [NSURLRequest requestWithURL:url];
	[streamingmusic loadRequest:request];
	NSString *connected = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
    if (connected == NULL) {
		UIAlertView *alertstreaming = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"Sorry, you need an internet connection for the stream to work. Please check your settings and restart the app. Thanks!" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
		[alertstreaming show];
		[alertstreaming release];
	} 
    else 
    {
    }
    [super viewDidLoad];
}
You can put some NSLog in the else function if u want to.
LHT is offline   Reply With Quote
Reply

Bookmarks

Tags
alertview, webview

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: 329
5 members and 324 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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