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.
Related
I am very new to iOS development.
My app is a drawing app where you can have multiple pages, and these pages accessed with a drag forwards or backwards -- like iBooks.
The 'Draw View' only accepts input from Apple Pencil, but I can't figure out how to get the view controller to change the page only if the input is a finger. I tried using touchesBegan on the view controller and getting touch.type but this didn't work; it seems only the view receives the touches -- not the view controller. This is a huge problem because it means I can't draw with the pencil -- I can only change the page.
TLDR: how do I get my view controller to not change page when Apple Pencil is the input source?
EDIT: this is not a duplicate question. I already know how to differentiate between a touch of a finger and a touch of the pencil (using touch.type) as I said in the question. however, only the view is receiving touches when I touch the screen, not the view controller. So how do i tell the view controller the type of the touch the view is receiving.
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.
I have a tableView and on a 3D touch its cells display the View Controller behind it along with a UIPreviewAction that will share a URL that the "peeked" View Controller fetches.
The problem is that the server doesn't always come back with the URL before the UIPreviewActions are initialised and I don't want to give the option to share if the URL doesn't exist (certain pages don't have a URL).
Is there any way to reload the UIPreviewActions after the View Controller has loaded?
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.
I am trying to figure out how to create a "Now Playing" view similar to the one in the Music app and the Spotify app.
Here are a few images of what I'm trying to re-create:
Creating the view is not the problem. The part I'm having trouble with is how to keep the view on the screen at the bottom with the now playing information on it, but then when clicked, flicked, or swiped up, make it show like a modal.
Is this something that can be set up in Storyboard, or is it completely custom? How would you set this up?
Thank you in advanced for the help.
My guess is for Spotify it's custom as their implementation predates storyboards being... I'll use the term "friendly" to 3rd party developers.
However if you're building with the latest Xcode and iOS SDK this should be fairly easy to accomplish by building a container view controller wherein the child view would be everything in the upper quadrant, and you would effectively make that parent viewcontroller (with the now playing view area on the bottom) the root view controller.
As for the flicking / tapping, that's probably just a typical gesture recognizer that loads a modal. I can't recall if Apple's implementation is panning, but Spotify's is. My guess with them is as you as you tap down they load a new VC that's mostly obscured off screen and that's what actually gets panned in.