GithubHelp home page GithubHelp logo

svwebviewcontroller's Introduction

SVWebViewController

SVWebViewController is a simple inline browser for your iOS 7 app.

SVWebViewController

SVWebViewController features:

  • iPhone and iPad distinct UIs
  • full landscape orientation support
  • back, forward, stop/refresh and share buttons
  • Open in Safari and Chrome UIActivities
  • navbar title set to the currently visible web page
  • talks with setNetworkActivityIndicatorVisible

Installation

CocoaPods

I'm not a big fan of CocoaPods, so tend to not keep it updated. If you really want to use SVWebViewController with CocoaPods, I suggest you use pod 'SVWebViewController', :head to pull from the master branch directly. I'm usually careful about what I push there and is the version I use myself in all my projects.

Manually

  • Drag the SVWebViewController/SVWebViewController folder into your project.
  • #import "SVWebViewController.h"

Usage

(see sample Xcode project in /Demo)

Just like any UIViewController, SVWebViewController can be pushed into a UINavigationController stack:

SVWebViewController *webViewController = [[SVWebViewController alloc] initWithAddress:@"http://google.com"];
[self.navigationController pushViewController:webViewController animated:YES];

It can also be presented modally using SVModalWebViewController:

SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:@"http://google.com"];
[self presentViewController:webViewController animated:YES completion:NULL];

SVWebViewControllerActivity

Starting in iOS 6 Apple uses UIActivity to let you show additional sharing methods in share sheets. SVWebViewController comes with "Open in Safari" and "Open in Chrome" activities. You can easily add your own activity by subclassing SVWebViewControllerActivity which takes care of a few things automatically for you. Have a look at the Safari and Chrome activities for implementation examples. Feel free to send it as a pull request once you're done!

Credits

SVWebViewController is brought to you by Sam Vermette and contributors to the project. If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by creating new issues. If you're using SVWebViewController in your project, attribution is always appreciated.

svwebviewcontroller's People

Contributors

aburgel avatar alexruperez avatar bastos avatar bmichotte avatar d11wtq avatar filipbec avatar fogh avatar gabrielrinaldi avatar gcamp avatar gdorion avatar jamesstout avatar johntmcintosh avatar juliensaad avatar matthewmayer avatar mshibanami avatar ngreenstein avatar olicarbo avatar oliverletterer avatar pushpak avatar samvermette avatar sandosh avatar smuellner avatar stevemoser avatar zzd258147 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svwebviewcontroller's Issues

custom actions / activities

To support custom implementations in the action sheet and to provide a kind-of-future-proof implementation I am suggesting and going to implement a property excludedActivityTypes (NSArray of NSStrings) plus a set of string constants SVActivityTypeSafari, SVActivityTypeMail and SVActivityTypeCopyToPasteboard that replace the current bit set availableActions.

Custom activities derive from SVActivity and can be provided via the property applicationActivities (NSArray of SVActivity). Each activity implements the methods

  • - (NSString *)activityTitle
  • - (void)performActivity

and can use the derived property webView inside performActivity to complete its work.

SVActivity as well as the standard activities are implemented in SVWebViewController.h/.m. The current implementation of actionSheet:clickedButtonAtIndex: and pageActionSheet will be refactored to take advantage of this design.

Highly appreciating any comments as I will post my progress here, too.

Podspec

It doesn't seem as though the latest version of the repo is being pulled from Cocopods. Might want to check into it.

Please add semantic version tags.

I’ve recently added SVWebViewController to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, SVWebViewController doesn't have version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

Swipe to go backward and forward

I think it'd be pretty neat if your history was stored in a singleton, and you could add a swipe UIGesture to load the previous page, or if you loaded the previous page, to go back to the page you were on.

If there's interest, I could add this...

"Hide bars on scroll" option would be nice

Not a bug, more a feature request. It would be really nice if the modal view controller would have a option to hide all bars on scrolling down. If you scroll up, they appear again. Saw that feature in a lot of apps.

Podspec iOS 7 only ?

Is there any reason why the Podspec iOS 7 only ?

I tested the latest 1.0 release and it works fine on iOS 6 also. Only difference i see is the safari and chrome images which should be different for iOS 6.

barsTintColor not applied to toolbar buttons

I'm trying to use barsTintColor to change an SVModalWebViewController's toolbar color to black. Code:

SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:@"http://google.com"];
webViewController.barsTintColor = [UIColor blackColor];
[self presentModalViewController:webViewController animated:YES];

The color is applied to the left button item and most of the toolbar as expected, but the buttons on the right side of the toolbar (reload, back, forward, action) and the area behind them aren't affected.

toolbar color issue

iOS 5.1, iPad, Xcode 4.4.1

Manage Actions

what would be great is if we could edit the actions.

f.e.

webViewController.actionEmailEnabled = NO;
webViewController.actionSafariEnabled = YES;
webViewController.actionCopyEnabled = YES;

something like this, or as an array.
(as you can see, a 'copy link' action would be cool)

Changing Done button with image on Model View

I have following code to display the model view of SVWevViewController but I cant see the change on SVView DONE button ? why ?

NSString *linkURL = [[[self allItems] objectAtIndex:[self itemNo]] valueForKey:@"link"];

UIImage *buttonImage = [UIImage imageNamed:@"btn_left"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:linkURL];
webViewController.navigationItem.leftBarButtonItem = customBarItem;

[self presentModalViewController:webViewController animated:YES];

JavaScript Action

Thanks a lot for great library. I'm trying to use it with a web site link, but when click some links I don't get any action. Then an action sheet is displayed with title "JavaScript" and two buttons "Open" and "Cancel". I have used "Open" button, but nothing happened. I would appreciate your help.

SVWebViewController crashes on iPad with iOS 7

I get the following error when running the stock SVWebViewController from master on an iPad with iOS7 (or the simulator).

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[UIToolbarButton imageForState:]: unrecognized selector sent to 
instance 0x8ab3260'

While Xcode breaks for the exception in viewWillDisappear on the previous controller, I found out that the following changes make the crash disappear:

In updateToolbarItems comment out these lines (in the iPad branch):

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, toolbarWidth, 44.0f)];
toolbar.items = items;
toolbar.barStyle = self.navigationController.navigationBar.barStyle;
toolbar.tintColor = self.navigationController.navigationBar.tintColor;

Since the UIToolbar is not used on the iPad I don't see any reason to have the code in there.

Sadly I am not proficient enough in iOS development to explain how this code could cause the previous crash.

Add initWithURLRequest

I hit a use-case where I had to open POST requests in SVWebViewController.

Therefore it would be nice to be able to init a controller with an NSURLRequest.

The change was straightforward, changing the URL property to URLRequest.

I can submit a PR with my monkey-patched version, if you're interested in this.

HTML select dropdown not working

I've recently updated to the latest version of SVwebviewcontroller, since then whenever I visit a page which contains a 'HTML select dropdown' and tap on it the webview does not present a UIPicker as it used to.

Not sure where to start, anyone else had this?

Thanks

Is it possible to use with storyboard?

Hi, nice library... Thanks for this wonderful plugin.
It is possible to use it with storyboard? I have a nice storyboard with segue, but the perfectly integration isn't actually possible. Have there anybody any idea?

share button crashes on iOS8

Using the modal web view controller in an iPad page sheet, clicking the share button gives:

Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x7fb38c8e7fe0>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'

Can't get view to rotate to landscape

Hi there,
My app doesn't support landscape but my users have asked if your browser control could flip for them. How can I enable landscape orientation support for just your view controller?

No orientation information for non-tablet

Right now:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if(deviceIsTablet)
    return YES;
}

Leads to a warning on the iphone console saying that this method should say YES to something.
I think it should be:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if(deviceIsTablet)
    return YES;
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Clicking text field in web view in landscape

When presenting as a full-screen modal, to, say, google.com, clicking in the text field will cause the modal to shrink at the top for some reason. It may be due to auto layout, I don't know.

I fixed it by adding:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardDidShow:)
                                             name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWillHide:)
                                             name:UIKeyboardWillHideNotification object:nil];

Then setting the frame to 1024x768 again in those methods.

Remove/Hide or Update title of SVModalWebViewController

When I am using SVModalWebViewController in my app, I am often providing a link to the user which will redirect to the final page. But while redirecting, the title of the page gets stuck at 'Redirecting to request website'

I want to remove/hide the title of the page or have the ability to update it.

Is this possible?

popViewController

I'd like to explicitly stop loading on the webview when popping the view controller but the webview is an internal property so I can't do this without modifying your class.

i'm looking to do this because i'm getting crashes when a user hits back and pops the SVWebViewController off the stack while it's still loading.

is there an ideal way to go about this, short of making the webview public?

Create from interfacebuilder

Hi Sam

Beautiful library! I am hoping to use it in my app Tunepal. A question for you...

Whats the best way to use this in a tab (in a tab bar) in interface builder? What I have done is:
Created subclasses of SVWebViewController
Overiden the - (id)initWithCoder:(NSCoder *)inCoder method and called:
return [[super initWithCoder:inCoder]initWithURL:url];

Set the tab to be a subclass of SVWebViewController

Somehow I dont think this is right :-)

What is happening is:

The tabs are displaying ok with the appropriate url, but not handling rotations correctly. Portrait is ok, but when I rotate to landscape, the width stays the same.. It could be because my MainWindow.mm which contains the tab controller implements autolayout and perhaps this "property" is getting passed into the SVWebViewConroller, however my map tab displays and rotates ok...

Any ideas?

Bryan

Rotating SVWebViewController to landscape and going back crash

I push the SVWebViewController, web page loads, everything is fine. If I remain in portrait mode then pushing back button works fine. However, if I rotate the device to landscape mode while looking at the SVWebViewController and then push the back button the app crashes. The view that it's trying to go back to only supports portrait mode. I have two other views that allow rotation that work fine when going back. Not really sure what's going on as I've tried a lot of things and nothing has an effect. Also, when it crashes it's just breaking in Main and not anywhere useful.

CachedWebPage didn't work for me

Hi Sam,

Great library, very useful for my project.

I ran into one issue trying to use

  • (id)initWithWebContent:(NSURL *)url withCachedPage:(NSString *)cachedPage.

It appears that in loadView, the loadHTMLString command is getting immediately overwritten by the loadURL command, resulting in a blank screen when offline, even when the cached web page is present. I fixed it by putting the following two lines in viewDidAppear.

[self loadURL:self.URL];
self.view = mainWebView;

I'm new to GitHub, should I make this into a pull request or is it fine as an issue?

Greg

EXC_BAD_ACCESS due to deferred delegate callbacks

If you present the non-modal (didn't try the modal) VC like so:

SVWebViewController *vc = [[[SVWebViewController alloc] initWithAddress:@"http://www.someslowsite.com"] autorelease];
[self.navigationController pushViewController:vc animated:YES];

Then quickly hit the Back button while the site is loading, you can often get a bad access fault thrown. This was tracked down to not clearing the delegate (mainWebView.delegate = nil;) before the VC gets autoreleased.

Not sure where the best place to implement this fix would be but I put it in viewWillDisappear: and re-registered the delegate in viewWillAppear: because there's no existing dealloc method.

Releasing navItem too early, bad access

So at least on an iphone, when the web view controller is introduced without a navigation controller (for instance, if it's presented modally) you create a new nav bar and nav item, and then release the nav item ... but then in setupToolbar, you access navItem again, after it's been released.

Draft new release

Looking at the recent patches a new release tag with updated PodFile would be great.

SVWebViewController+ Youtube player troubles

Hi I am using your "SVModalWebViewController.h","SVWebViewController.h" , to play youtube video , which is posting by our customer. I need to track touch events in SVWebViewController web view. This will load you tube player in your web view , with URL what we are sending. But , If others trying to search , or play other video it allows. We need to have control on this. Other than supplied URL , other actions except play should be disabled. Hope you get my point. How to do this? Kindly help me out.

Thanks,
Femina

Toolbar consistently animates from the right

When presenting SVWebViewController via the SVModalViewController, the bottom toolbar will slide in from the right as if the view is being pushed. I feel like there is a simple reason for this but I can't figure it out, I'm still quite inexperienced.

Also in SCWebViewController.m when calling self.navigationController setToolbarHidden:YES animated:NO; the toolbar still animates (and from the right). If I call [self.webViewController.navigationController setToolbarHidden:NO animated:animated]; in SVModalWebViewController.m then the toolbar doesn't rush in from the right.

I'm still unsure how to do a pull request (or if that's the right thing to do in this situation). Let me know what I should do.

Q: Why is the title not updated on subsequent page loads?

While I guess there are better ways to observe a changing title (KVO on the UIWebView), I was wondering why you explicitly disregard title changes after the initial load?

See:

if (self.navigationItem.title == nil) {

Would you be interested in a PR which removes that above line and uses KVO to get all title updates (for example from JS) (untested, but I think this should work).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.