私はあなたが欲しいもののデモを作成します。これはさらに説明されています..
以下はviewcontroller.hファイルコードです
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
NSURL *Url;
}
@property(nonatomic,retain)IBOutlet UIWebView *webVctr;
@end
これはあなたの問題を解決するのに役立つかもしれませんありがとう
以下はviewcontroller.mファイルのコードです
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize webVctr = _webVctr;
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"%@",request);
Url = [request URL];
// if ([[UrlParts objectAtIndex:(1)] isEqualToString:@"NeverGonnaFindMe"]) {
// CONVERT TO STRING AN CLEAN
NSString *urlResources = [Url resourceSpecifier];
urlResources = [urlResources stringByReplacingOccurrencesOfString:@"?" withString:@"/"];
// SEPORATE OUT THE URL ON THE /
NSArray *urlResourcesArray = [urlResources componentsSeparatedByString:@"/"];
// THE LAST OBJECT IN THE ARRAY
NSString *urlParamaters = [urlResourcesArray objectAtIndex:([urlResourcesArray count]-1)];
// SEPORATE OUT THE URL ON THE &
NSArray *urlParamatersArray = [urlParamaters componentsSeparatedByString:@"&"];
if([urlParamatersArray count] == 1) {
NSString *keyValue = [urlParamatersArray objectAtIndex:(0)];
NSArray *keyValueArray = [keyValue componentsSeparatedByString:@"="];
if([[keyValueArray objectAtIndex:(0)] isEqualToString:@"page"]) {
NSLog(@"%@",[keyValueArray objectAtIndex:1]);
}
[self dismissModalViewControllerAnimated:YES];
return NO;
}
return YES;
}
// ACTIVITY INDICATOR
- (void)webViewDidStartLoad:(UIWebView *)webView{
/// [_activityIndicator startAnimating];
NSLog(@"Resting to server");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
// [_activityIndicator stopAnimating];
NSLog(@"Finish request server");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"Error");
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *fullAuthUrlString =[[NSString alloc] initWithFormat:@"www.google.com?page=235"];
NSURL *authUrl = [NSURL URLWithString:fullAuthUrlString];
NSURLRequest *myRequest = [[NSURLRequest alloc] initWithURL:authUrl];
[self.webVctr loadRequest:myRequest];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end