Skip to content

Instantly share code, notes, and snippets.

@weiran
Created February 19, 2013 08:56
Show Gist options
  • Save weiran/4984162 to your computer and use it in GitHub Desktop.
Save weiran/4984162 to your computer and use it in GitHub Desktop.
- (void)mobilizerButtonPressed:(id)sender {
UIButton *mobilizerButton = (UIButton *)sender;
NSString *mobilizerURLString = kMobilizerURL;
NSURL *requestURL;
if ([_currentURL.absoluteString hasPrefix:mobilizerURLString]) {
requestURL = _mobilizedURL;
[mobilizerButton setSelected:NO];
} else if (!_currentURL || [_currentURL.absoluteString isEqualToString:@""]) {
return;
} else {
_mobilizedURL = _webView.request.URL;
NSString *encodedURLString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)_currentURL.absoluteString, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8));
NSString *mobilizerURL = [NSString stringWithFormat:[mobilizerURLString stringByAppendingString:@"%@"], encodedURLString];
requestURL = [NSURL URLWithString:mobilizerURL];
[mobilizerButton setSelected:YES];
[MBProgressHUD showHUDAddedTo:self.webView animated:YES];
}
[_webView stopLoading];
NSURLRequest *request = [NSURLRequest requestWithURL:requestURL];
[_webView loadRequest:request];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment