ios - Adding subview to WKWebView below JS Dialog - ios

When adding subview, something like [self.webView.scrollView addSubview:test]; everything works fine.
Problem is javascript alert and it's dimmed screen, because alert is below my newly added view. JS alerts and dialogs should be always on top.
Any ideas?

Javascript alerts from the web view are part of that web view and not separate UIViews.
If you want something to appear above the main web content and below the javascript alert (which is also web content), then it will need to be web content itself.
One way to do this would be to make it another javascript-generated object, not UIView.
Alternatively, you could have a second web view that only displays javascript alerts, and have your UIView appear below your new (second) web view, but then you'd have to manage the relationship between the two web views.

Related

How to add view in top of view hierarchy in Swift?

I have been using this:
UIApplication.sharedApplication().keyWindow?.rootViewController!.view.addSubview(self.customView)
To add a modal view over all the views in the view hierarchy in app.
But this is giving me problem. It adds subview as expected sometimes but sometimes it doesn't' work.
In what case this wont work and what's the best way to add modal view in view hierarchy like UIAlertView.
Depending on what's happening, there can be more than one UIWindow at a time - for example, if a system alert shows up, you will have two separate windows (one for your view controller, one for the alert itself).
A similar example can be made for the system keyboard. If the keyboard has focus, that will be your keyWindow.
A way of making sure you are adding the subview on top of all windows, could be: UIApplication.sharedApplication().windows.last?.addSubview(yourSubView).
I've also seen people using the application delegate, with: UIApplication.sharedApplication().delegate?.window.

How to create banner images that pan across screen using Xcode/Swift?

How do you create a banner (say, above a UITableView or something) that will switch images after a given time, or upon swipe. It then recycles through after a set number of images. See the below provided example from the IF app).
Also, I'm not necessarily looking for code here, but simply general features of Xcode I'd use to make it happen (ie, UIImageView within a ContainerView with gesture recognizers or something). Any ideas?
Here's the first image:
Then the beginning of the transition:
Then the second image in place:
This is an example of how to get that exact behavior using UIPageViewController. From the documenation:
A page view controller lets the user navigate between pages of content, where each page is managed by its own view controller object. Navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change.

Manage multi tabs (pages) in UIWebView

I want to manage multiple page or tabs in UIWebView like default iPhone Safari See Screen shot for better understand :
http://s14.postimg.org/xie4imi35/i_OS_Simulator_Screen_shot_24_May_2014_7_56_03_PM.png
Is that possible to manage this in UIWebView.
Three things I want to tell you here:
See Answer for multi tab in UIWebView here.
Look at HGPageScrollView library and WKPagesCollectionView on Github.
I saw that in UINavigationController when we move from ParentViewController to ChildViewController and then move back again state of Parent view is maintained. I am trying to use that in implementing multi tabs in UIWebView.

Simple iOS app to show my site in UIWebView *with* back / refresh controllers

Looking all over for a simple Xcode project that will load my web site in a UIWebView that has the default Safari controllers for back / refresh the page - but can't seem to find one.
All I could find was a great template project, but it didn't have the controllers. And since I am very new to iOS development, I can't figure out how to add the controllers.
Can anyone help me out with complete source for something like that?
Thanks
Add a navigationbar above or a toolbar under the webview
Put two barbuttonitems/buttons into the bar, one for back and one for forward. Of course you can also use the segmented control
Set the webview's delegate to the view controller of the view
In the TouchDown-actions of the buttons, call webView's goBack: or goForward: methods
For the method references, see here: https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instm/UIWebView/goBack
The same can of course be done with reload (the method is called refresh), and this SO even shows an example of how to do it:
Refresh a UIWebView

How to expand UIWebView on click

I'm working on an Ad SDK for iOS and I have a narrow banner-size UIWebView that displays a complex HTML that I receive from an ad server. I don't know anything about structure of that HTML (i.e. it may change).
At some point user taps on that UIWebView, which causes the content of that ad to become full-screen, so I need to expand my UIWebView and show it in the modal view (via presentModalViewController).
Is there a way to either take my existing UIWebView and reattach it to my new modal view while keeping its state (whatever user clicked on)?
Or alternatively how can I simulate touch on UIWebView, since I could create new UIWebView in my modal view and load the same HTML, but then I need to re-create its state after initial tap by somehow sending a tap event programmatically.
Use UITapGestureRecognizer, make that WebView full-screen and move to the front layer.

Resources