Method One: Apply to App not applicable to UIWebView
Nsurl *Itunesurl;//Process a linkshare/tradedoubler/dgm URL to something IPhone can handle- (void) Openreferralurl: (Nsurl *) referralurl{nsurlconnection*con = [[Nsurlconnection alloc] Initwithrequest:[nsurlrequest Requestwithurl:referralurl]Delegate: Self startimmediately:yes];}//Save The most recent URL in case multiple redirects occur//"Itunesurl" is a Nsurl property in your class declaration-(Nsurlrequest *) connection: (Nsurlconnection *) connection willsendrequest: (nsurlrequest *) Request Redirectresponse :(Nsurlresponse *) response{Itunesurl=[Response URL]; if([[Itunesurl.host lowercasestring] Hassuffix:@"itunes.apple.com"]) {[Connection Cancel]; [Self connectiondidfinishloading:connection]; returnNil; } Else { returnrequest; }}//No more redirects, use the last URL saved- (void) Connectiondidfinishloading: (Nsurlconnection *) connection{[[UIApplication sharedapplication] openurl:itunesurl];}
Method Two: Apply to UIWebView
-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (nsurlrequest *) _request Navigationtype: ( Uiwebviewnavigationtype) Navigationtype { *host=[[_request url].host lowercasestring]; if ([Host Hassuffix:@ "itunes.apple.com"]) {[ [uiapplication sharedapplication] openurl:[_request URL]]; return NO; }}
The specific effect can sweep the code to measure Try: