-Webkit-Overflow-Scrolling: Touch' Broken for Initially Offscreen Elements in iOS7

How to add a touch event to a UIView?

In iOS 3.2 and higher, you can use gesture recognizers. For example, this is how you would handle a tap event:

//The setup code (in viewDidLoad in your view controller)
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];

//The event handling method
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer
{
CGPoint location = [recognizer locationInView:[recognizer.view superview]];

//Do stuff here...
}

There are a bunch of built in gestures as well. Check out the docs for iOS event handling and UIGestureRecognizer. I also have a bunch of sample code up on github that might help.

How to re-size UITextView when keyboard shown with iOS 7

Whilst the answer given by @Divya lead me to the correct solution (so I awarded the bounty), it is not a terribly clear answer! Here it is in detail:

The standard approach to ensuring that a text view is not hidden by the on-screen keyboard is to update its frame when the keyboard is shown, as detailed in this question:

How to resize UITextView on iOS when a keyboard appears?

However, with iOS 7, if you change the text view frame within your handler for the UIKeyboardWillShowNotification notification, the cursor will remain off screen as described in this question.

The fix for this issue is to change the text view frame in response to the textViewDidBeginEditing delegate method instead:

@implementation ViewController {
CGSize _keyboardSize;
UITextView* textView;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

textView = [[UITextView alloc] initWithFrame:CGRectInset(self.view.bounds, 20.0, 20.0)]; textView.delegate = self;
textView.returnKeyType = UIReturnKeyDone;
textView.backgroundColor = [UIColor greenColor];
textView.textColor = [UIColor blackColor];
[self.view addSubview:textView];

NSMutableString *textString = [NSMutableString new];
for (int i=0; i<100; i++) {
[textString appendString:@"cheese\rpizza\rchips\r"];
}
textView.text = textString;

}

- (void)textViewDidBeginEditing:(UITextView *)textView1 {
CGRect textViewFrame = CGRectInset(self.view.bounds, 20.0, 20.0);
textViewFrame.size.height -= 216;
textView.frame = textViewFrame;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
CGRect textViewFrame = CGRectInset(self.view.bounds, 20.0, 20.0);
textView.frame = textViewFrame;
[textView endEditing:YES];
[super touchesBegan:touches withEvent:event];
}

@end

NOTE: unfortunately textViewDidBeginEdting fires before the UIKeyboardWillShowNotification notification, hence the need to hard-code the keyboard height.

(Angular 4) How to a Bind Global Touch Event Handler to Disable iOS Safari Page Drag?

Found the solution to this problem! Add this to head in index.html or define elsewhere in your JS scripts:

<script>
document.ontouchmove = function(event) {
event.preventDefault();
}
</script>

How to disable the magnifying glass in UIWebview?

No, the loupe is inextricably linked to selection. To disable it, you will have to disable selection entirely (you can use -webkit-user-select: none to do that).

UITableView selected cell doesn't stay selected when scrolled

Had the same problem, selected cell's accessoryView disappeared on scroll. My co-worker found pretty hack for this issue. The reason is that in iOS 7 on touchesBegan event UITableView deselects selected cell and selects touched down cell. In iOS 6 it doesnt happen and on scroll selected cell stays selected. To get same behaviour in iOS 7 try:

1) Enable multiple selection in your tableView.

2) Go to tableView delegate method didSelectRowAtIndexPath, and deselect cell touched down with code :

   NSArray *selectedRows = [tableView indexPathsForSelectedRows];
for(NSIndexPath *i in selectedRows)
{
if(![i isEqual:indexPath])
{
[tableView deselectRowAtIndexPath:i animated:NO];
}
}

Fixed my problem! Hope it would be helpful, sorry for my poor English btw.

iOS: How to access the `UIKeyboard`?

How about using -[UIApplication beginIgnoringInteractionEvents]?

Also, another trick to get the view containing the keyboard is to initialize a dummy view with CGRectZero and set it as the inputAccessoryView of your UITextField or UITextView. Then, get its superview. Still, such shenanigans is private/undocumented, but I've heard of apps doing that and getting accepted anyhow. I mean, how else would Instagram be able to make their comment keyboard interactive (dismiss on swipe) like the Messages keyboard?



Related Topics



Leave a reply



Submit