#import
#import
#import
#import
#import
typedef NS_ENUM(NSInteger, UIWebViewNavigationType) {
UIWebViewNavigationTypeLinkClicked,
UIWebViewNavigationTypeFormSubmitted,
UIWebViewNavigationTypeBackForward,
UIWebViewNavigationTypeReload,
UIWebViewNavigationTypeFormResubmitted,
UIWebViewNavigationTypeOther
};
typedef NS_ENUM(NSInteger, UIWebPaginationMode) {
UIWebPaginationModeUnpaginated,
UIWebPaginationModeLeftToRight,
UIWebPaginationModeTopToBottom,
UIWebPaginationModeBottomToTop,
UIWebPaginationModeRightToLeft
};
typedef NS_ENUM(NSInteger, UIWebPaginationBreakingMode) {
UIWebPaginationBreakingModePage,
UIWebPaginationBreakingModeColumn
};
@class UIWebViewInternal;
@protocol UIWebViewDelegate;
#pragma - mark - UIWebView
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIWebView : UIView {
@private
UIWebViewInternal *_internal;
}
@property(nonatomic,assign) id delegate;
@property(nonatomic,readonly,retain) UIScrollView *scrollView NS_AVAILABLE_IOS(5_0);
- (void)loadRequest:(NSURLRequest *)request; // 加载请求
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL; // 加载HTML文件
// data为本地的数据文件的加载data文件 MIMEType是文件类型
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName baseURL:(NSURL *)baseURL; // 通过这个方法来将网络上的数据保存到本地
@property(nonatomic,readonly,retain) NSURLRequest *request;
- (void)reload; // 重新加载
- (void)stopLoading; // 停止加载
- (void)goBack; // 返回上一页
- (void)goForward; // 进入下一页
@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack; // 是否返回上一页
@property(nonatomic,readonly,getter=canGoForward) BOOL canGoForward; // 是否进入下一页
@property(nonatomic,readonly,getter=isLoading) BOOL loading; // 是否正在加载
// 执行 JavaScript 代码
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;
@property(nonatomic) BOOL scalesPageToFit; // 页面自动适应屏幕
@property(nonatomic) BOOL detectsPhoneNumbers NS_DEPRECATED_IOS(2_0, 3_0);
@property(nonatomic) UIDataDetectorTypes dataDetectorTypes NS_AVAILABLE_IOS(3_0);
@property (nonatomic) BOOL allowsInlineMediaPlayback NS_AVAILABLE_IOS(4_0);
@property (nonatomic) BOOL mediaPlaybackRequiresUserAction NS_AVAILABLE_IOS(4_0);
@property (nonatomic) BOOL mediaPlaybackAllowsAirPlay NS_AVAILABLE_IOS(5_0);
@property (nonatomic) BOOL suppressesIncrementalRendering NS_AVAILABLE_IOS(6_0);
@property (nonatomic) BOOL keyboardDisplayRequiresUserAction NS_AVAILABLE_IOS(6_0);
@property (nonatomic) UIWebPaginationMode paginationMode NS_AVAILABLE_IOS(7_0);
@property (nonatomic) UIWebPaginationBreakingMode paginationBreakingMode NS_AVAILABLE_IOS(7_0);
@property (nonatomic) CGFloat pageLength NS_AVAILABLE_IOS(7_0);
@property (nonatomic) CGFloat gapBetweenPages NS_AVAILABLE_IOS(7_0);
@property (nonatomic, readonly) NSUInteger pageCount NS_AVAILABLE_IOS(7_0);
@end
@protocol UIWebViewDelegate
@optional
// 是否开始加载请求,返回yes可以加载,返回no不能加载
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
// 开始加载后调用
- (void)webViewDidStartLoad:(UIWebView *)webView;
// 加载结束后调用
- (void)webViewDidFinishLoad:(UIWebView *)webView;
// 加载过程中出现错误后调用,可多次被调用
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;
@end