I'm trying to debug my app because the app closes when I click the link.
I want an AlertView when you click a link to the AppStore, with the choises OK or Cancel, Cancel obviously doing nothing and OK opening the AppStore.
Can anyone help me with this?
The code:
I want an AlertView when you click a link to the AppStore, with the choises OK or Cancel, Cancel obviously doing nothing and OK opening the AppStore.
Can anyone help me with this?
The code:
Code:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([request.URL.host hasSuffix:@".apple.com"]){
theURL = [request.URL retain];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Go to the AppStore?"
message:@""
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK"];
[alert show];
[alert release];
return NO;
}
return YES;
}
// defining action for pressing 'OK' and calling method theURL
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
// by clicking 'OK' go to the url
if (buttonIndex == 1){
[[UIApplication sharedApplication] openURL: theURL];
}
[theURL release];
}