[아이폰 앱 개발] A basic UIWebView

Web view

A basic UIWebView.
CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame]; [webView setBackgroundColor:[UIColor whiteColor]]; NSString *urlAddress = @"http://www.google.com"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [self addSubview:webView]; [webView release];
Posted by 오늘마감

댓글을 달아 주세요

A basic UIWebView

Web view

A basic UIWebView.
CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame]; [webView setBackgroundColor:[UIColor whiteColor]]; NSString *urlAddress = @"http://www.google.com"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [self addSubview:webView]; [webView release];

'아이폰어플개발정보' 카테고리의 다른 글

Display Images  (0) 2010.10.12
Application Frame얻기  (0) 2010.10.12
A basic UIWebView  (0) 2010.10.12
Animation: Move an object  (0) 2010.10.12
Info button  (0) 2010.10.12
UIView 높이 폭변경  (0) 2010.10.12
Posted by 오늘마감
TAG a, BASIC, UIWebView

댓글을 달아 주세요

How to intercept navigation in a UIWebView

How to intercept navigation in a UIWebView

UIWebView is a great control to display formatted text (using HTML language). That text might contain links that you want to intercept in Objective-C and do a specific action (push a new view for example).

You can do this by implementing UIWebViewDelegate protocol…


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {      NSArray *parts = [[[request URL] absoluteString] componentsSeparatedByString:@"#language_id_"];         if ([parts count] == 2) {               TranslationViewController *vc = [[TranslationViewController alloc] initWithNibName:@"PrayerTranslationView" bundle:nil];                [self presentModalViewController:vc animated:YES];              [vc release]; return FALSE;     }       return TRUE; }

In that method you can check the requested URL and decide if you want to allow the standard flow, navigation to that URL (by returning TRUE),  or do something else instead. In the example above we are showing a new view.


http://surgeworksmobile.com/iphone/how-to-intercept-navigation-in-a-uiwebview

Posted by 오늘마감

댓글을 달아 주세요

How to override UIWebView links request action with your own custom method

How to override UIWebView links request action with your own custom method

Ivan Kalaica

If you have a Web View in your view you can call a custom action when the user taps on a link in that UIWebView instance.

Here’s how…

Set the delegate of that UIWebView class instance on your instance of UIViewController class. Now just copy & paste the following code into your class.  This code implements the UIWebView instance and adds a call to the custom action (method).

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
if (overrideLinksSwitch.on == TRUE) {
[self myMethodAction];
[myWebView stopLoading];
return YES;
}
else {
<>return YES;
}
}
return YES;
}

You can download an example app here.

http://surgeworksmobile.com/iphone/how-to-override-uiwebview-links-request-action-with-your-own-custom-method
Posted by 오늘마감

댓글을 달아 주세요

How to override UIWebView links request action with your own custom method

How to override UIWebView links request action with your own custom method

If you have a Web View in your view you can call a custom action when the user taps on a link in that UIWebView instance.

Here’s how…

Set the delegate of that UIWebView class instance on your instance of UIViewController class. Now just copy & paste the following code into your class.  This code implements the UIWebView instance and adds a call to the custom action (method).

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
if (overrideLinksSwitch.on == TRUE) {
[self myMethodAction];
[myWebView stopLoading];
return YES;
}
else {
<>return YES;
}
}
return YES;
}

You can download an example app here.

http://surgeworksmobile.com/iphone/how-to-override-uiwebview-links-request-action-with-your-own-custom-method
Posted by 오늘마감

댓글을 달아 주세요