How Judgment webview page is loaded? - objective-c

How Judgment webview page is loaded? Let me tell you the page is loading.
Also, unable to open web pages loaded in Webview, like some of the below URLs.
- (void)awakeFromNib {
NSString *urlString = #"http://www.google.com";
// Insert code here to initialize your application
[[_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
}
- (IBAction)googleOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.google.com"];
}
- (IBAction)baiduOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.baidu.com"];
}
- (IBAction)yahooOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.yahoo.com"];
}
How can I open a URL with a way to pass parameters?

If you want to know when a website has loaded, link the WebFrameLoadDelegate protocol, and implement webView:didFinishLoadForFrame: to know if the webpage has loaded.
Use webView:didStartProvisionalLoadForFrame: to know if the webpage has start loading.
Check your connection to the internet, and see if you can open the websites from another web browser. If it works, then check if your IBAction's are linked correctly to your buttons.
What do you mean by open a URL with parameters? If you mean by having a textfield which allows users to search keywords on certain websites such as Google, just do http://www.google.com/search?q=%yoursearch, replacing %yoursearch with the users input.

Related

fire webViewDidFinishLoad before document.onload

I need to inject some js code on my webpage being loaded in my UIWebView before any other script is executed. Unfortunately it seems that HTML document.onload is executed before objective-c webViewDidFinishLoad callback.
Check this test code out:
- (void)viewDidLoad {
[super viewDidLoad];
webView.delegate = self;
[webView loadHTMLString:#"<body onload=\"alert('this is from html')\"></body>" baseURL:nil];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[webView stringByEvaluatingJavaScriptFromString:#"alert('this is from obj-c')"];
}
Message "this is from html" is always shown before message "this is from obj-c".
I need to get the other way around considering that I cannot control my html page, so I have to assume there's a document.onload function being called.
...ok found...
I need to use webViewDidStartLoad instead of webViewDidFinishLoad.
Surprisingly to me, jscode injected during webViewDidStartLoad callback is available to the loaded HTML page. This means to me that the UIWebView javascript engine is not reset after webViewDidStartLoad which is fine to me.

UIWebView, can a button on a page trigger an app's view change?

I load up a UIWebView in my app which displays html text and a sign out button.
Is it at all possible that when the user taps the html button it can then change the view? ie: it will go back in navigation of the app to the previous view?
Any examples of this being done?
Can this also be done in java for my Android version?
Edit: If I place an event using JS or something on the button can I then use a listener within the app's web view to go back a view?
What you could do is...
When one of your buttons is pressed, it actually attempts to send the user to a new URL (eg, through a href="", or javascript redirect). But, in your app's code you can use UIWebView's delegate methods to intercept the loading of the URL and instead run some app-based code.
Eg.
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *_url = [NSString stringWithFormat:#"%#", request.URL];
if ([_url rangeOfString:#"?signout"].location != NSNotFound) {
[self userRequestsLogout];
return NO;
}
return YES;
}
Don't forget that UIWebView also has;
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
Hopefully this helps.

Am I adding URL correctly to SLComposeViewController

-(void) vPostStuffs:(UIViewController *) parent withImage:(UIImage *) image andText:(NSString *) text andURL: (NSString *) URL
{
// Create a compose view controller for the service type Twitter
SLComposeViewController *mulitpartPost = [SLComposeViewController composeViewControllerForServiceType:self.strSLServiceType];
if (text)
{
[mulitpartPost setInitialText:text];
}
if (URL)
{
[mulitpartPost addURL:[NSURL URLWithString:URL]];
}
if (image)
{
[mulitpartPost addImage:image];
}
[parent presentViewController:mulitpartPost animated:YES completion:nil];
}
In Android, facebook will display a screen shot of URL instead of simply writing the URL in the post. In my iOS application, facebook simply display the URL
What am I missing?
Is this related to Facebook SLComposeViewController URL shows up in body if both URL and image present
Here is the thing. If I do not display the image, if I get rid [mulitpartPost addImage:image]; then the URL doesn't show up as anything.
In twitter, URL and pictures do not show up. Even though after pressing post it does shows up on the twitter.
In facebook, URL screenshot never shows up no matter what even though it shows up after posting.
In twitter, those with multiple twitter accounts will have twitter post to the wrong account.

How to open web browser with UIWebView

Hey guys,
On my Xcode project, I am trying to open a web browser at the click of one of my buttons, but here's what I'm really trying to do. First of all, I am opening a web browser using this example code:
NSURL *fanPageURL = [NSURL URLWithString:#"fb://profile/210227459693"];
if (![[UIApplication sharedApplication] openURL: fanPageURL]) {
NSURL *webURL = [NSURL URLWithString:#"http://www.facebook.com/pages/Blackout-Labs/210227459693"];
[[UIApplication sharedApplication] openURL: webURL];
}
[super viewDidLoad];
Now this code works properly, but the problem is that it's closing my application and opens the link in the Safari application, which is not what I want. I went the other way around by creating another view (after click the button), then inserted a UIWebView using Interface Builder, but it still didn't work. So I was hoping someone can help me out how to open this link within my app instead of closing my app and opening the link in the Safari app, thanks
Look at SVWebViewController. It's a ready made UIViewController subclass with a UIWebView in it and all you need to do to show it is
SVWebViewController *webViewController = [[SVWebViewController alloc] initWithAddress:#"http://google.com"];
[self.navigationController pushViewController:webViewController animated:YES];
There is also a modal version, see the Usage Section.
You'll need to create a UIViewController subclass that has UIWebView as a subview, and show that when the button in tapped.

How to connect web url in iphone application development?

I am new to iphone application.I have 6 uiimages in a view.fifth image is facebook and sixth one is twiter.Under images,Iplaced two roundrectbuttons named as click5 and click6. My requirement is,when i click on those images,I have to go to login pages of facebook and twitter.how can i do this?can anyone send me sample example and explain it detai?
If you want to send the user to the website using Safari, you invoke the openURL: method in the UIApplication class, like this:
NSURL *facebookURL = [NSURL URLWithString:#"http://www.facebook.com"];
[[UIApplication sharedApplication] openURL:facebookURL];
When assigning a button to an action, you use the UIButton's addTarget:action:forControlEvents:, providing an event handler as action. Say you're setting this up in viewDidLoad, it might look like this:
- (void) viewDidLoad {
[myButton addTarget:self
action:#selector(btnClicked:)
forControlEvents:UIControlEventTouchUpInside];
}
/**
* Click/tap event handler for some buttons
*/
- (IBAction) btnClicked:(id)sender {
// Check which button was pressed.
if (sender == self.click5) {
// ...
}
else if (sender == self.click6) {
// ...
}
}
You know the very easiest way to do this? With the free 3rd party component ShareKit. It wraps the Facebook and Twitter (and several other social network) APIs to literally make it a three-line deal to post things.
I used it for the first time in the last app I built and I was SHOCKED at how easy to use it was.