Programming/Non programming

Sunday, March 28, 2010

iPhone:UIWebview to load URL:

iPhone:

How load URL in UIWebView

1. Create a UIWebView in I.B and link that with UIWebView declaration in code.
2. Call the below code in viewDidLoad (or) viewWillAppear

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]] ];

When you run this screen, it will pickup the URL and show in Webview.

Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.


Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

iPhone:Adding URL to the text?

iPhone:

How to add URL link to the text:

There are two ways to do that.

1. Via under button controls:

i) Create a button in view. Make the button as 'custom' so that you will not see button borders at runtime and will look like just a text.
ii) Create a button action like below:

-(IBAction) LaunchURL : (id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:/www.corpusmobilelabs.com/"]];
}

Click on the button, you should be success!

2. Via under TouchEvent on a control:

i) Create a UILabel and write text like your URL www.yourwebsite.com
ii) Make sure UILabel linked with UILabel declaration in code and UserInteraction checkbox is
enabled in I.B.
iii) Add the below touch event code in your code, which will execute the launching URL only when the created UILabel is touched.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint point = [[touches anyObject] locationInView:urlLabel];
if( [urlLabel hitTest:point withEvent:nil] )
[ [UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www. yourwebsite.com"] ];
else
[super touchesEnded:touches withEvent:event];
}

That's it, you got to go!!!

Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..