Sign up ×

Ok guys, so I am new to iOS programming.

Im trying to build a VERY SIMPLE WebView iOS App that loads an External URL and all the Javascript (@external server too) associated with it.

The following code loads the page perfectly but when I click on the "Login" button, the Javascript it calls doesnt seem to do anything.

- (void)loadView
    self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    UIWebView *webView =[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    webView.scalesPageToFit = YES;
    [[self view] addSubview:webView];

This is the code for the Login button in the external HTML file:

<a id="btnLogin" data-role="button" data-icon="star" href="javascript:__doPostBack(&#39;btnLogin&#39;,&#39;&#39;)"><span>Login</span></a>

I have also tried using different PhoneGap/Cordova/ChildBrowser tutorials and everything seems very outdated/not working.

If possible, I also need GeoLocation (web page requests current position for certain features). I basically just need it to work exactly as it does in Safari.

Please Help!

share|improve this question

2 Answers 2

Xcode will add any javascript resource files to the Compile Sources of your project by default. They should be removed from this and placed instead in the Copy Bundle Resources of your project. You can find these in the Build Phases tab of your Target, when you select the project. Every time I've had my JS not respond, this has been the cause.

share|improve this answer
up vote 0 down vote accepted

After doing extensive research, I found out that UIWebView's User-Agent is not properly recognized by ASP.NET. This causes authentication issues with ASP.NET applications.

NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"User Agent Here", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];  

After changing the user-agent the authentication process worked successfully.

share|improve this answer

Your Answer


