In my app I have a WebView Containing a Twitter account for and every tweet there is a link take you to a specific website
my question : can I replace the links of those webpages by read more ?
You can override the link itself so that when the user clicks, instead of it jumping to that website, it calls your method.
Create an instance of UIWebViewDelegate,and implement the method:
"webView:shouldStartLoadWithRequest:navigationType:
Sent before a web view begins loading
content."
...and return "false" when the link clicked is one of those external links.
Then, also, do whatever custom action you wanted to do - e.g. popup a new UIView that contains the "read more" content you wanted to display
Related
I've made a Facebook app to implement fecebook login on my php Saas solution.
I can't add a domain in the settings->advanced section.
A dialog is shown. I write the domain and click the [add] button. Now a spinner is showing and just keeps spinning. I've tried everal computers and mobile devices. It is the same everywhere.
What do I do wrong?
I have set the domains in then settings -> basic sections and I have added all the url callbacks.
image af dialog with spinning button - with protocol
EDIT: It is the same thing with or without protocol. The placeholder in the field states to enter an URL but either with or without the protocol part nothing happens.
image af dialog with spinning button - without protocol
I need to be able to figure out what is the previous page in a UIWebView hierarchy so that I can disable the back button on certain instances. So, to clarify:
User is on page A - clicks on link
User is now on page B - clicks on link
User is now on page C - clicks on the **back** button
User is now on page B
I need to be able to know that "previous" page from page B is page A. The method I'm using right now unfortunately only figures out the previous page the user was in in general. So in the situation above, it thinks the previous navigated page is page C.
Any help would be appreciated! :)
Each time the user clicks on a link and a new page loads, your web view delegate gets a message. So "write down" that information each time! Now you know what "back" means.
Also, you can talk JavaScript to the UIWebView. JavaScript gives you a history object. A lot of the key functionality in UIWebView is through JavaScript! Apple hasn't bothered to duplicate it in Objective-C properties, because, well, why bother?
years later....
In researching this same scenario, I came up with a nice solution.
Inside webViewDidFinishLoad, check for the property "canGoBack" and hide or unhide your back button accordingly. Thought this was too cool not to share. :)
if (self.webView.canGoBack)
{
self.backButton.hidden = NO;
}
else
{
self.backButton.hidden = YES;
}
I am new in iOS development and trying to make a button called backhome which is only visible when the user tap on the changes the native Website I set in the loadRequest.
Now my question: Is there any way to detect if the user leaves the website I set for e.g in a if statement?
Set a delegate for your "UIWebView" object and then write a method to respond to:
webView:shouldStartLoadWithRequest:navigationType:
The request parameter in that call has a URL and from there, you can tell if the user has left your default website.
I am just building an app for my first time. I've created it so that I open it and it opens web view and I have a button called "Save" (so it's just a web view inside the app with a little button below it). I would like to be able to save a website when I visit it. It doesn't need to label the save or anything, I just want it to save and I can click another button called "sites" and it will display my list of saved websites.
You will have to decide on some kind of storage method. A simple one would be create an NSMutableArray of the sites. Depending on the needs of the application, you could change this to something different. Then, saving the site is as simple as inserting an object that represents the page (maybe an NSURL or an NSString with the URL). The question Get current URL of UIWebView discusses several ways of getting a URL from a webview. You can then decide on a way to display the list of saved sites. Once a site is selected, you just have to pass it back to the webview.
Suppose my app will load a local web page which is stored in my app bundle. I want to push the view or present a view when the user click a link or an image inside that web page. How to do this? Let's make this be general question: how to communicate with my app from a local web page?
Thank you.
Use "webview.request.URL.absoluteString" to get the request-string of the clicked link in the delegate-method "webViewDidFinishLoad:" or "webViewDidStartLoad:".
then you can scan this url for some special substring.
For example you could make a link like ".../index.php?iPhone_action=abcdef".
In the delegate-methods you can check if the link has the substring "?iPhone_action=" and if it does, then put the part of the link, whick follows "?iPhone_action=" in a NSString.
(in our example it would be "abcdef").
Depending on the value of this NSString you could fire a action in your app.
There is an undocumented method to catch the event when you click on a link in UIWebView. You can do whatever you want to do in that method.Search on google/stackoverflow for it. Or see my answer in this stackoverflow post.
Show alert view when click on a link