Disabling iOS Elastic Scrolling on an embedded YT IFrame - ios

I'm making an app in Adobe AIR targeting iOS 4.0+ and Android 2.3+. I've tried to disable iOS elastic scrolling for the embedded YT video: When the user presses the player's IFrame the whole video pans over and I can't seem to find a way around this.
I've tried adding event listeners to prevent this behavior but it doesn't work.
By the way, I'm aware that I can't really control what happens in the IFrame. A quick and dirty solution would be to put elements directly over the frame, like a transparent canvas or a div that would catch the events. Not ideal at all, because users won't be able to press the buttons on the player.
Any ideas or suggestions?
Thanks!

I found a solution.
You need access to UIWebView (the underlying iOS implementation under StageWebView) to disable elastic scrolling.
Once you have your Adobe Native Extension (ANE) setup, its relatively simple. (A great ANE Wizard/Generator is found here https://github.com/freshplanet/ANE-Wizard)
For iOS 5 its straightforward: webView.scrollView.bounces = NO;
If you want to support iOS 4, it gets a bit more complex. You don't have the convenience of webView.scrollView, so you need to find this view manually.
An Objective-C code block that handles both iOS 4 and 5 would be something like this:
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:#"5.0" options:NSNumericSearch] != NSOrderedAscending) {
// iOS 5 is straightforward
webView.scrollView.bounces = NO;
}
else {
// iOS 4 requires a bit more of work
UIScrollView *scrollView = nil;
for (UIView *subview in [webView subviews])
{
if ([subview isKindOfClass:[UIScrollView class]]) {
scrollView = (UIScrollView *)subview;
}
}
if (scrollView != nil) {
scrollView.bounces = NO;
}
}
Hope this helps!

Related

Remove UIWebFormAccessory on iOS keyboard

Hi I am trying to remove the UIWebFormAccesory that appears on top of the keyboard on iOS when entering text to a WKWebView text field. I have a slight hack below based on previous answers to this question, but they are all outdated and no longer work. I've added a picture below, with a red box around the bar I'm talking about:
The code below works if I run it 2x in a row, but then causes weird behavior on the keyboard, which eventually crashes the application.
for (UIWindow* wind in [[UIApplication sharedApplication] windows]) {
for (UIView* currView in wind.subviews) {
if ([[currView description] containsString:#"UIInputSetContainerView"]) {
for (UIView* perView in currView.subviews) {
for (UIView *subView in perView.subviews) {
if ([[subView description] containsString:#"UIWebFormAccessory"]) {
[subView setHidden:true];
[subView removeFromSuperview];
// CGRect f = perView.frame;
// CGRect n = CGRectMake(0, f.origin.y, f.size.width, f.size.height-44.0);
// [perView setFrame:n];
}
}
}
}
}
}
Was wondering if anyone has had any luck with this? I'm using Objective-C but a swift solution would be fine as well, thanks for the help!
Also here are the older threads that I have looked at, but haven't had any luck with:
How to find UIWebView toolbar (to replace them) on iOS 6?
Remove form assistant from keyboard in iPhone standalone web app

is it possible to remove the (i) info button and place some video controllers over 360 video Google VR?

The title says it all! but to be more clear, please check this screenshot. This is a 360 video playback using the Google VR https://developers.google.com/vr/ios/ but I want to know if it is possible to remove this little (info) button? and instead overlay our own set of video controlers?
Google allow you to create a custom GVRView which doesn't have the (i) icon - but it involves creating your own OpenGL code for viewing the video.
A hack working on v0.9.0 is to find an instance of QTMButton:
let videoView = GVRVideoView(frame: self.view.bounds)
for subview in self.videoView.subviews {
let className = String(subview.dynamicType)
if className == "QTMButton" {
subview.hidden = true
}
}
It is a hack though so it might have unintended consequences and might not work in past or future versions.
Well, I have an answer to my own question. Alright, the (i) button cannot be removed. at leased not for now. check this answer
Hi. The (i) is intentional and designed to let users and other
developers understand the feature. It links to a Google help center
article. We do not currently allow developers to disable it.
https://github.com/googlevr/gvr-ios-sdk/issues/9#issuecomment-208993643
GVRVideoView *videoView = [[GVRVideoView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
for (UIView *view in videoView.subviews) {
if ([view isKindOfClass:[UIButton class]] ) {
if ([NSStringFromClass([view class]) isEqualToString:#"QTMButton"] ) {
[view removeFromSuperview];
}
}
}

Can't move keyboard view iOS9 swift

I need to implement a dismissive keyboard (swiping down to dismiss) like the one in the stock messages app on iOS.
I have this code to get the keyboard view:
func keyboardWillShowWithNotification(notification:NSNotification) {
let keyboardView = accessoryView.superview
}
And I connected the UIPanGestureRecognizer of the tableView to detect when I need to start moving the keyboard down.
func handleTableViewPan(gr:UIPanGestureRecognizer) {
let location = panGestureRecognizer.locationInView(self.view)
let offset = ... //calculated correctly
keyboardView.frame.origin.y = originalKeyboardFrame.origin.y + offset
}
The method worked fine with iOS 8 but with iOS 9 it seems like the keyboard is hold in place a little different so I can't move it.
Maybe someone encountered the same problem and can help me.
Thank you.
In iOS 9 there is a new window for keyboard named UIRemoteKeyboardWindow, so when you are using accessoryView.superview you will get a wrong view.
To get correct view try to find it from window hierarchy directly:
(objective-c code)
-(UIView*)getKeyboardInputView {
if([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
for(UIWindow* window in [[UIApplication sharedApplication] windows])
if([window isKindOfClass:NSClassFromString(#"UIRemoteKeyboardWindow")])
for(UIView* subView in window.subviews)
if([subView isKindOfClass:NSClassFromString(#"UIInputSetHostView")])
for(UIView* subsubView in subView.subviews)
if([subsubView isKindOfClass:NSClassFromString(#"UIInputSetHostView")])
return subsubView;
} else {
return accessoryView.superview;
}
return nil;
}
P.S. Taken from DAKeyboardControl https://github.com/danielamitay/DAKeyboardControl/pull/98

Is there a way to enable parallax for a Form Sheet on iPad?

thanks for turning up :-)
I noticed that on the iPad the Form Sheet view does not have any iOS 7 parallax effects, and I would actually like to incorporate this because I think it kinda looks cool.
Well this is what I have and it doesn't have that, so is there a way to do this? How would one go about doing it? I've googled and googled and google has finally failed me because nothing appropriate is appearing.
Thanks :)
This can be done with some effort.
First off, you need to know how to add parallax to a view in general:
I have the following category method for UIView to make it easy:
- (void)addDepthMotionX:(CGFloat)x y:(CGFloat)y {
Class clazz = NSClassFromString(#"UIInterpolatingMotionEffect");
if (clazz) {
BOOL reverse = NO;
if (CGAffineTransformEqualToTransform(self.transform, CGAffineTransformMakeRotation(-M_PI_2)) || CGAffineTransformEqualToTransform(self.transform, CGAffineTransformMakeRotation(M_PI_2))) {
reverse = YES;
}
UIInterpolatingMotionEffect *eff = [[clazz alloc] initWithKeyPath:#"center.x" type:reverse ? UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis : UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
eff.maximumRelativeValue = #(x);
eff.minimumRelativeValue = #(-x);
[self addMotionEffect:eff];
eff = [[clazz alloc] initWithKeyPath:#"center.y" type:reverse ? UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis : UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
eff.maximumRelativeValue = #(y);
eff.minimumRelativeValue = #(-y);
[self addMotionEffect:eff];
}
}
The code is guarded so it won't crash if called from other than iOS 7 (or later).
Now to add parallax to a view you simply do:
[someView addDepthMotionX:10 y:10]; // pick an appropriate depth value
The final step to your question is to apply this to the root of the view controller you are displaying.
Here's code you can add in the viewWillAppear: method of the view controller. Adjust to meet your needs:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (self.isBeingPresented || self.isMovingToParentViewController) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && self.modalPresentationStyle == UIModalPresentationFormSheet) {
[self.navigationController.view.superview addDepthMotionX:15 y:15];
}
}
}
One issue with this code is if the user rotates the iPad 90 degrees after the form sheet is presented, the parallax effect needs to be updated. But this will get you started.

Disabling zoom-in zoom-out functionality of the UIWebView

I am new to iOS development and I am developing an application which will show and web page in UIWebView. I want to get rid of the default zoom-in and zoom-out functionality of the webview.
This is in the Apple Documentation:
#property(nonatomic) BOOL scalesPageToFit
Discussion
If YES, the webpage is scaled to fit and the user can zoom in and zoom out. If NO, user zooming is disabled. The default value is NO.
Interface Builder Approach:
Make sure that the "Scale pages to fit" tick box in the right-side column of the interface builder when you click on your webview is un-ticked. It's right at the top.
You're also going to need to un-tick the box that says "Multiple Touch" around half way down. That will disable pinching to zoom.
Code Approach:
You can also do it programmatically with this code:
webView.scalesPageToFit = NO;
You're also going to want to add:
webView.multipleTouchEnabled = NO;
That will disable the ability to pinch and zoom, since it disables the ability to use multiple fingers in an action, and pinching requires two, obviously!
set the UIWebView property scalesPageToFit to NO, will disable the user zooming
myWebView.scalesPageToFit = NO;
One simply needs to do:
myWebView.scalesPageToFit = NO;
and also disable the pesky pinch to zoom:
webView.multipleTouchEnabled = NO;
For me the ideal solution was, surprinsingly, in the html side only. Just add this in <head>:
<meta name="viewport" content="user-scalable=0" />
I don't recommend to use webView.scalesPageToFit = false because it brings issues like making everything 4x bigger. I also did not use initial-scale=1.0, maximum-scale=1.0 nor minmum-scale=1.0
UIScrollView *scrollView = [webView.subviews objectAtIndex:0];
scrollView.delegate = self;//self must be UIScrollViewDelegate
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return nil;
}
try this ... It works..
Disable bouncesZoom of the scrollView will solve your problem. Give it a try!
webView.scrollView.bouncesZoom = false
When inheriting from UIWebView you can implement. (Works from iOS 5, lower not sure)
- (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView
{
return nil;
}
Try this:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return nil;
}
Swift Solution
Simply set the value mentioned above to false: webView.scalesPageToFit = false
To add to the answers, this will work:
webView.scrollView.multipleTouchEnabled = NO;
i am also struggle at first when i use webview scroll event after that i fond the below code for disable the scroll in webview and this also remove the multitouch gestures function in that particular webview.
[[[theWebView subviews] lastObject] setScrollEnabled:NO];
here theWebView is the name of my UIWebView..
use this code in webViewDidFinishLoad function ,,, its really helpful to me,..

Resources