Saturday, January 4, 2014

How to use webview controls?

I have this problem, do not use!

Thank you! ! !
Reply:
 / / The header file: 
/ *
Copyright 2007 Lee S. Barney

This file is part of QuickConnectiPhoneHybrid.

QuickConnectiPhoneHybrid is free software: you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(At your option) any later version.

QuickConnectiPhoneHybrid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with QuickConnectiPhoneHybrid. If not, see.
* /

# Import

# Define kAccelerometerFrequency .001 / / Hz

@ Interface BrowserViewController: UIViewController {
UIWebView * webView;
}

@ Property (nonatomic, retain) UIWebView * webView;


@ End


/ / The class file:
/ *
Copyright 2007 Lee S. Barney

This file is part of QuickConnectiPhoneHybrid.

QuickConnectiPhoneHybrid is free software: you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(At your option) any later version.

QuickConnectiPhoneHybrid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with QuickConnectiPhoneHybrid. If not, see.
* /
# Import "BrowserViewController.h"

@ Implementation BrowserViewController

@ Synthesize webView;

- (Id) init
{
/ *
if (self = [super init]) {
}
* /
return self;
}

- (Void) loadView
{
NSLog (@ "loading view");

/ / The base view for this view controller
UIView * contentView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor blueColor];

/ / Important for view orientation rotation
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
self.view.autoresizesSubviews = YES;
/ / Create a frame that will be used to size and place the web view
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y - = 20.0; / / shift the display up so that it covers the default open space from the content view
UIWebView * aWebView = [[UIWebView alloc] initWithFrame: webFrame];
self.webView = aWebView;
/ / AWebView.scalesPageToFit = YES;
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
/ / Set the web view and acceleration delagates for the web view to be itself
[AWebView setDelegate: self];
/ / Determine the path the to the index.html file in the Resources directory
NSString * filePathString = [[NSBundle mainBundle] pathForResource: @ "index" ofType: @ "html"];
/ / Build the URL and the request for the index.html file
NSURL * aURL = [NSURL fileURLWithPath: filePathString];
NSURLRequest * aRequest = [NSURLRequest requestWithURL: aURL];
/ / Load the index.html file into the web view.
[AWebView loadRequest: aRequest];

/ / Add the web view to the content view
[ContentView addSubview: webView];

[AWebView release];
[ContentView release];
}

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
/ / Return YES for supported orientations.
return YES;
}
- (Void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
{

if (fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
NSString * result = [webView stringByEvaluatingJavaScriptFromString: @ "rotate (0)"];
/ / NSString a = * result;
NSLog (result);

}
else {
[WebView stringByEvaluatingJavaScriptFromString: @ "rotate (1)"];
}

/ / [Self.webView sizeToFit];
/ / CGRect curBounds = [[UIScreen mainScreen] bounds];
/ / [Self.webView setBounds: self.origViewRectangle];
/ / [[UIScreen mainScreen] bounds]]
/ / NSLog (@ "orienting");
}

- (Void) accelerometer: (UIAccelerometer *) accelerometer didAccelerate: (UIAcceleration *) acceleration
{

NSString * javaScriptCall = [NSString stringWithFormat: @ "accelerate (% f,% f,% f)", acceleration.x, acceleration.y, acceleration.z];

[WebView stringByEvaluatingJavaScriptFromString: javaScriptCall];
/ / Use a basic low-pass filter to only keep the gravity in the accelerometer values ​​
/ / _accelerometer [0] = acceleration.x * kFilteringFactor + _accelerometer [0] * (1.0 - kFilteringFactor);
/ / _accelerometer [1] = acceleration.y * kFilteringFactor + _accelerometer [1] * (1.0 - kFilteringFactor);
/ / _accelerometer [2] = acceleration.z * kFilteringFactor + _accelerometer [2] * (1.0 - kFilteringFactor);
}

- (Void) didReceiveMemoryWarning
{
[Super didReceiveMemoryWarning]; / / Releases the view if it doesn't have a superview
./ / Release anything that's not essential, such as cached data.
}
- (Void) webView: (UIWebView *) webView didFailLoadWithError: (NSError *) error
{
NSLog (@ "An error happened during load");
}
- (Void) webViewDidStartLoad: (UIWebView *) webView {
NSLog (@ "loading started");
}
- (Void) webViewDidFinishLoad: (UIWebView *) webView {
NSLog (@ "finished loading");
}

- (Void) dealloc
{
[Super dealloc];
}


@ End

Shining example code using
Reply:
Ah. . So much? ? ?

Examples of code where's ah?

I try to, first thank you, ah, will be a statement posted! ! !
Reply:

google come
Reply:
Give me the URL, good! ! !
Reply:
http://tetontech.wordpress.com/2008/05/23/uiwebview-example-code/
I remember over the wall out
Reply:
There is no special software over the wall on mac os?
Reply:
How you want to use, you can put in another layout Webview attached above as (layout.addView (webview) ;) You can also use it directly out
Reply:
The reply was deleted at the moderator 2011-11-15 16:23:51

No comments:

Post a Comment