I am trying to send the UIWebView page Title to UINavigationBar.
I would also like it if a user clicks on a link the UINavigationBar shows a back button but if on the home page hide the back button.
to retrieve the title page into an UIWebView you can use it:
myNavigationBar.title = [myWebView stringByEvaluatingJavaScriptFromString:#"document.title"];
If you want to go back you can do that:
if ([myWebView canGoBack]){
[myWebView goBack];
}
To know if the user has loaded a new page you must set the UIWebViewDelegate. For more information see the UIWebView Class Reference and the UIWebViewDelegate Protocol Reference
As of iOS8 you should just use WKWebView and its title property.
Related
So basically I want a UITableView to display a bunch of websites in the RootView. Then from there, using the UINavigationController, I would like to open a different view (WebViewController) and load the URL specified in the button, in the UIWebView.
What would be the best way to do this?
EDIT: Okay so there are basically two views. The first view is the RootViewController, which is includes the UINavigationController. Basically this will include some buttons (that have custom URL's already assigned to them) that will change & load the URL in the webView using the following.
-(IBAction)linkButton:(id)sender
{
NSURL *url = [NSURL URLWithString:#"http://URL_HERE.com"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
The second view will be called the "CodeView" and it will include the UIWebView object dubbed webView.
So what I'm trying to accomplish is this: After clicking on one of the buttons in the RootViewController, it will switch to the CodeView and load whatever URL has been assigned to the button itself, in the UIWebView object. Then of course, have the option to return to the RootViewController via the UINavigationController, which is just common sense when it comes to using a Navigation Controller.
Well, you have to put the root view inside a navigation controller (i suupose you are already doing this) then for each button you tap you could create a new codeview with the url and push it to the navigation controller.
This way you could have your webview inside the codeview. Did i miss something?
I am designing a webView with a close button. When the application is launched, it opens the given url. When the button is touched, i want to close the webView.
I need some button event which closes the webView. Thank you for your answers.
UIWebView inherits from UIView. So the answer is: It depends!
If you're using a UINavigationController and used
[[self navigationController] pushViewController:newUIWebController];
you can close your UIView by using
[self.navigationController popViewControllerAnimated:YES];
If you're using some other method to display your view (like addSubView) you can utilize the corresponding method like removeFromSuperview.
when you click "Share" in my app you'll show an ActionSheet like this:
Take photo
Select photo from Library
Cancel
You tap "Take photo" and you'll see an ImagePicker, with "presentModalViewController".
You take a photo and you select "OK" in the ImagePicker.
Here, I want the photo just taken in a new view with other label. Like this:
(new view)
Little photo (just taken)
- Label 1 (ex. Title of photo)
- Label 2 (ex. Location of photo)
and a button "Share" for sharing your photo and its infos.
How can I do this? I'm stopped after take the photo. How can I send my photo (in a imageview) to another view?
Thanks
for this,
make some global varible in appDelegate class and make them property.
for saving Image make UIImage object in app delegate and for title and path make string variables and make all these : property then.
then when you select image from modelView at the selection time you must set app delegate properties(image,title,path).and navigate to other page and on viewWillAppear of new page
set your controls (ImageView and labels) by these objects.
I hope, it helps you. You need to code this logic.
Some one already suggested for that by using appDelegate.
you can do in other way too.
just declare some variable like imagePath and imageTitle in the 2nd view controller. and set property to them like
#property (nonatomic,retain) NSString *imagePath;
And then in the 1st view controller access those variables like
secondViewControllerObj.imagePath = #"Give Image Path Here";
then you can access the imagePath in the 2nd View Controller as self.imagePath
Regards,
Satya
is it possible to open an in-app browser that loads a pdf and the takes you back to the nib just like the mailcomposition does with the in-app email? If so, can anyone please help.
You should be able to use a UIWebView controlled by a custom UIViewController, which you present using the presentModalViewController:animated: method in the view controller that wants to pop up the PDF.
1) Create a .xib and corresponding view controller (both named WebViewViewController here). This should include a UIWebView (to display the PDF) and a UIButton (to close the modal view & return to your original view).
2) Present your WebViewViewController as a modal view. This will "pop-over" your current view with the new view.
WebViewViewController *webViewVC = [[WebViewViewController alloc] initWithNibName:#"WebViewViewController" bundle:nil];
//I am showing it over a Navigation Controller, you may be using something different.
[self.navigationController presentModalViewController:webViewVC animated:YES];
[webViewVC release];
3) In your WebViewViewController, wire up an IBAction method to your "Close" button. In that method use this to dismiss the "pop-over" view.
//
[self dismissModalViewControllerAnimated:YES];
Let me know if you need help with loading the PDF into the UIWebView.
How can I control the title which appears in the UINavigationController with a web page which appears in a UIWebView?
I am trying to get the UINavigationController title to reflect the title of the web page.
In your webViewDidFinishLoad method, you'll need to call something like
NSString * result = [myWebView stringByEvaluatingJavaScriptFromString:#"document.title"];
Then you'll set up the navigation controller title:
self.navigationItem.title=result;
Unless I'm missing something from your problem description, this should work.