Skip to content

fix UI bug on iOS 7 iPhone #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 6 additions & 1 deletion SVWebViewController/SVModalWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (id)initWithURL:(NSURL *)URL {
self.webViewController = [[SVWebViewController alloc] initWithURL:URL];
if (self = [super initWithRootViewController:self.webViewController]) {
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self.webViewController
target:self
action:@selector(doneButtonClicked:)];

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
Expand All @@ -47,4 +47,9 @@ - (void)viewWillAppear:(BOOL)animated {
self.navigationBar.tintColor = self.barsTintColor;
}

- (void)doneButtonClicked:(id)sender
{
[self.webViewController dismissViewControllerAnimated:YES completion:NULL];
}

@end
2 changes: 2 additions & 0 deletions SVWebViewController/SVWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@interface SVWebViewController : UIViewController

@property (nonatomic, strong) UIWebView *webView;

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;

Expand Down
24 changes: 16 additions & 8 deletions SVWebViewController/SVWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ @interface SVWebViewController () <UIWebViewDelegate>
@property (nonatomic, strong) UIBarButtonItem *stopBarButtonItem;
@property (nonatomic, strong) UIBarButtonItem *actionBarButtonItem;

@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) NSURL *URL;

- (id)initWithAddress:(NSString*)urlString;
Expand Down Expand Up @@ -60,7 +59,7 @@ - (id)initWithURL:(NSURL*)pageURL {
}

- (void)loadURL:(NSURL *)pageURL {
[self.webView loadRequest:[NSURLRequest requestWithURL:pageURL]];
[self.webView loadHTMLString:@"<html><body></body></html>" baseURL:nil];
}

#pragma mark - View lifecycle
Expand Down Expand Up @@ -232,6 +231,10 @@ - (void)webViewDidStartLoad:(UIWebView *)webView {

- (void)webViewDidFinishLoad:(UIWebView *)webView {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
if ([webView.request.URL.absoluteString isEqualToString:@"about:blank"]) {
[self.webView loadRequest:[NSURLRequest requestWithURL:self.URL]];
return;
}

self.navigationItem.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
[self updateToolbarItems];
Expand Down Expand Up @@ -262,14 +265,19 @@ - (void)stopClicked:(UIBarButtonItem *)sender {
}

- (void)actionButtonClicked:(id)sender {
NSArray *activities = @[[SVWebViewControllerActivitySafari new], [SVWebViewControllerActivityChrome new]];

NSMutableArray *activities = @[].mutableCopy;
[activities addObject:[SVWebViewControllerActivitySafari new]];
[activities addObject:[SVWebViewControllerActivityChrome new]];
SVWebViewControllerActivity *weixinActivity = [NSClassFromString(@"HSUActivityWeixin") new];
// [weixinActivity performSelector:@selector(setShareTitle) withObject:self.navigationItem.title];
[weixinActivity performSelector:@selector(setShareDescription:) withObject:self.navigationItem.title];
SVWebViewControllerActivity *weixinMomentsActivity = [NSClassFromString(@"HSUActivityWeixinMoments") new];
// [weixinMomentsActivity performSelector:@selector(setShareTitle) withObject:self.navigationItem.title];
[weixinMomentsActivity performSelector:@selector(setShareDescription:) withObject:self.navigationItem.title];
[activities addObject:weixinActivity];
[activities addObject:weixinMomentsActivity];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[self.self.webView.request.URL] applicationActivities:activities];
[self presentViewController:activityController animated:YES completion:nil];
}

- (void)doneButtonClicked:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}

@end
5 changes: 0 additions & 5 deletions SVWebViewController/da.lproj/SVWebViewController.strings

This file was deleted.

3 changes: 0 additions & 3 deletions SVWebViewController/en.lproj/SVWebViewController.strings

This file was deleted.

3 changes: 0 additions & 3 deletions SVWebViewController/es-ES.lproj/SVWebViewController.strings

This file was deleted.

3 changes: 0 additions & 3 deletions SVWebViewController/es.lproj/SVWebViewController.strings

This file was deleted.

3 changes: 0 additions & 3 deletions SVWebViewController/fr.lproj/SVWebViewController.strings

This file was deleted.

2 changes: 0 additions & 2 deletions SVWebViewController/ja.lproj/SVWebViewController.strings

This file was deleted.

6 changes: 0 additions & 6 deletions SVWebViewController/zh-Hans.lproj/SVWebViewController.strings

This file was deleted.

3 changes: 0 additions & 3 deletions SVWebViewController/zh-Hant.lproj/SVWebViewController.strings

This file was deleted.