Preventing default context menu on longpress / longclick in mobile Safari (iPad / iPhone)

Thanks to JDandChips for pointing me to the solution. It works perfectly in combination with the longclick plugin. For documentation sake I’ll post my own answer to show what I did. HTML: <script type=”text/javascript” src=”https://raw.github.com/pisi/Longclick/master/jquery.longclick-min.js”></script> <p><a href=”http://www.google.com/”>Longclick me!</a></p> The Javascript already was OK: function longClickHandler(e){ e.preventDefault(); $(“body”).append(“<p>You longclicked. Nice!</p>”); } $(“p a”).longclick(250, longClickHandler); The fix … Read more

Difference between onbeforeunload and onunload

onunload is responsible for executing an instruction when the page is closed. It also causes issue with IE and AJAX. onbeforeunload is more efficient because it does not run in competition with the actual closing of the window and is triggered before onunload I know Opera used to not acknowledge onbeforeunload – not sure if … Read more

Full webpage and disabled zoom viewport meta tag for all mobile browsers

Unfortunately each browser has it’s own implementation of the viewport meta tag. Different combinations will work on different browsers. Android 2.2: viewport meta tag does not seem to be supported at all. Android 2.3.x/3.x: By setting user-scalable=no you disable the scaling of the viewport meta tag yourself as well. This is probably why your width … Read more

How to manage UIImageView content mode?

Please try this code, Hope it will work for you. set UIImageView contentMode to UIViewContentModeScaleAspectFill as below : imageView.contentMode = UIViewContentModeScaleAspectFill; set autoresizingMask of UIImageView as below : imageView.autoresizingMask = ( UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth );

UIGestureRecognizer and UITableViewCell issue

Instead of adding the gesture recognizer to the cell directly, you can add it to the tableview in viewDidLoad. In the didSwipe-Method you can determine the affected IndexPath and cell as follows: -(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == UIGestureRecognizerStateEnded) { CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView]; NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation]; UITableViewCell* swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath]; … Read more

Max/Min Scale of Pinch Zoom in UIPinchGestureRecognizer – iPhone iOS

Here is the solution that I figured out after using Anomie’s answer as a starting point. – (void)handlePinchGesture:(UIPinchGestureRecognizer *)gestureRecognizer { if([gestureRecognizer state] == UIGestureRecognizerStateBegan) { // Reset the last scale, necessary if there are multiple objects with different scales lastScale = [gestureRecognizer scale]; } if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) { … Read more