Change embedded youtube address in a UIWebView - iphone

I have an app that I'm trying to allow users to choose which youTube movie they play. I have a UIWebView with an embedded url, but I want that embedded code to able to change.
So far, I can't get this to change. This current setup only shows a blank white screen. When I put youtubeURL in place of the # it works fine, but not changeable. Any ideas how to change the URL? I have it setup so they can type a url that gets saved as youtubeURL, and that is the URL I want the UIWebView to show.
In my viewDidLoad:
youtubeURL = #"http://www.youtube.com/watch?v=HQ7R_buZPSo";
In my playMovie triggered by a button:
NSString* html = [NSString stringWithFormat:#"\
<html><head>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\" %# \" type=\"application/x-shockwave-flash\"\
width=\"1024\" height=\"748\"></embed>\
</body></html>", youtubeURL];
[self.view addSubview:youTubeView];
[youTubeView loadHTMLString:html baseURL:nil];
...
Thanks in advance!

So this started working randomly. I understand the fact that the user can't change the code, which is why I had youtubeURL to allow them to change the youtube link. I just had them type whatever they wanted into a UITextField, and saved it to a label as well as to youtubeURL. Works just fine now.

You'd have to have an input text box and then do youtubeURL = inputLabel.text (or just skip the youtubeURL variable altogether.
You can't have the user change the code.

Related

Html Tag doesn't get render properly in UIWebView

I am loading a html string in my UIWebView. Everything is working fine but when i tried to load a html containing <&reg > tag webview doesn't render it properly. Example if i have "Capital One® Secured" it is not rendering tag ® simplay display it as it is on the webview. Any help will be appreciated.
You do not need to enclose &reg in tag marks. Instead, you should use ® by itself where you want the registered trademark symbol.
E.g.
NSString *HTMLString = #"<p>Capital One® Secured</p>";
[webView loadHTMLString:HTMLString baseURL:nil];

Pinch To Zoom in UIWebView in iphone App

I am Developing simple App. I am accessing html pages on UIWebVIew. and I wanted to zoom that html pages with the help of zoom option
please help me out.
Zooming IN, OUT and Pinch are Built In feature of UIWebView. You don't need to write any code to achieve that.
Simply , Use your fingers.
On Simulator , you can use Option (Alt) and Shift Keys with Mouse.
Make your option Scale Page to Fit ON.
Try this below property
webView.scalesPageToFit = YES;
First of all set this property given below:
webView.scalesPageToFit = YES;
Then you have to set view port on meta data on the html string. In my case head tag was empty. Thats why I just replaced head with the with head containing meta tag.
htmlString = [htmlString stringByReplacingOccurrencesOfString:#"<head></head>"
withString:#"<head><meta name=\"viewport\" content=\"width=568\"/></head>"];
[webView loadHTMLString:htmlString baseURL:nil];
Using Storyboard :
There is built-in property of WebView ‘Scales Page To Fit’ which is false by default.
Select WebView -> Open Utilities Window -> Goto Attribute Inspector’
Set ‘Scales Page To Fit’ to true (Checkmark it)
Programmatically :
objWebView.scalesPageToFit = true

how to display string embedded with url in its back in ios 5

I am posting my APP name to my follower say EXAMPLEAPP i dont want to paste the url. I would like to implement it in html way say a href:"http://www.EXAMPLEAPP.com">EXAMPLEAPP /a>" this html code give me EXAMPLEAPP in blue color, on clicking it will redirect to the url to which it points at back end.
see the image:
In the image blue color words say "Greek alphabet"," Cumaean alphabet", "ruled early Romen" etc ..are having web links.
Exactly that kind of solution i m looking for is it possible? thanks in advance
you can display the embedded string but only using the UIWebView.
outputHTML=[[NSString alloc] initWithFormat:#"<body> %# </body>", stringData];
[webView loadHTMLString:string baseURL:nil];

link click detection in UIWebVIew in iPhone

I am using UIWebView. I have 4 links I know shouldStartLoadWithRequest function gets called when a link is clicked. But I need to differentiate, may be send some argument value when these links are clicked (different values). when i dubug the request holds the url of the page the webview is rendering.
I need to do dofferent things with info when these links are clicked.
thanks
You can check the links instead, like this
NSString *URLString = [[webview.request URL] absoluteString];

Google Calendar Mobile Version - embed

I want to embed a google calendar into an iphone app, my webview is fine, except I can't seem to get the URL I need to view the mobile version without having to logging in.
I know its possible as this is done in the twit app (See Screenshot below).
How can I do this?
Lets say the public google calendar is link text and I want to view the Mobile version of this page in a UIView.
The mobile view is available at link text, but you must first be logged into a google account.
Help Stackoverflow!
alt text http://posterous.com/getfile/files.posterous.com/norskben/RtIkoblEW9VsBE07dAQy9Sjjo4aRL2yjCRTCIx316y7ovsCXo9iKeGLL1AMx/photo.jpg
All under control now. Although I didn't find it possible to access the gp mobile view, it turned out infact to be just the agenda view of the normal view.
NSString *gcal = [NSString stringWithFormat:#"<html><meta name=\"viewport\" content=\"width=320\"/><iframe src=\"http://www.google.com/calendar/embed?showTitle=0&showNav=0&showTabs=0&showPrint=0&showCalendars=0&mode=AGENDA&height=600&wkst=2&hl=en_GB&src=northadelaidefitness#gmail.com&color=%23A32929&ctz=Australia%2FAdelaide\" style=\"border-width: 0pt;\" mce_style=\" border-width:0 \" frameborder=\"0\" height=\"400\" width=\"300\"></iframe>"];
[webview loadHTMLString:gcal baseURL:nil]; //load above html string (notice the viewport=320 for iphone resizing
webview.delegate = self; //add delegate for activity access
webview.scalesPageToFit =YES; //scale nicely