Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
457 changes: 457 additions & 0 deletions DZNWebViewController.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "07B768691DA00CD9007AC3C2"
BuildableName = "DZNWebViewController.framework"
BlueprintName = "DZNWebViewController"
ReferencedContainer = "container:DZNWebViewController.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "07B768691DA00CD9007AC3C2"
BuildableName = "DZNWebViewController.framework"
BlueprintName = "DZNWebViewController"
ReferencedContainer = "container:DZNWebViewController.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "07B768691DA00CD9007AC3C2"
BuildableName = "DZNWebViewController.framework"
BlueprintName = "DZNWebViewController"
ReferencedContainer = "container:DZNWebViewController.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
24 changes: 24 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions Source/Classes/DZNWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ typedef NS_OPTIONS(NSUInteger, DZNWebNavigationPrompt) {
@property (nonatomic, strong) DZNWebView *webView;
/** The URL identifying the location of the content to load. */
@property (nonatomic, readwrite) NSURL *URL;
/** The URL identifying the location of the content to load. */
@property (nonatomic, readwrite) NSURL *fileURL;
/** The supported navigation tool bar items. Default is All. */
@property (nonatomic, readwrite) DZNWebNavigationTools supportedWebNavigationTools;
/** The supported actions like sharing and copy link, add to reading list, open in Safari, etc. Default is All. */
Expand Down
32 changes: 27 additions & 5 deletions Source/Classes/DZNWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ @interface DZNWebViewController ()

@implementation DZNWebViewController
@synthesize URL = _URL;
@synthesize fileURL = _fileURL;

- (instancetype)init
{
Expand All @@ -54,13 +55,19 @@ - (instancetype)initWithURL:(NSURL *)URL
self = [self init];
if (self) {
_URL = URL;
_fileURL = nil;
}
return self;
}

- (instancetype)initWithFileURL:(NSURL *)URL
{
return [self initWithURL:URL];
self = [self init];
if (self) {
_URL = nil;
_fileURL = URL;
}
return self;
}

- (void)awakeFromNib
Expand Down Expand Up @@ -117,7 +124,11 @@ - (void)viewWillAppear:(BOOL)animated
}

if (!self.webView.URL) {
[self loadURL:self.URL];
if (self.URL != nil) {
[self loadURL:self.URL];
} else if (self.fileURL != nil) {
[self loadFileURL:self.fileURL];
}
}
}

Expand Down Expand Up @@ -354,10 +365,16 @@ - (void)setURL:(NSURL *)URL
}

if (self.isViewLoaded) {
[self loadURL:URL];
if ([URL isFileURL]) {
[self loadFileURL:URL];
_fileURL = URL;
_URL = nil;
} else {
[self loadURL:URL];
_URL = URL;
_fileURL = nil;
}
}

_URL = URL;
}

- (void)setTitle:(NSString *)title
Expand Down Expand Up @@ -452,6 +469,11 @@ - (void)loadURL:(NSURL *)URL
[self loadURL:URL baseURL:baseURL];
}

- (void)loadFileURL:(NSURL *)URL
{
[self.webView loadFileURL:URL allowingReadAccessToURL:URL];
}

- (void)loadURL:(NSURL *)URL baseURL:(NSURL *)baseURL
{
if ([URL isFileURL]) {
Expand Down