Archive for the ‘iOS’ Category

How to trigger UIButton with UITapGestureRecognizer


To trigger UIButton touch action within a view that has a UITapGestureRecognizer, you have to implement the the UIGestureRecognizerDelegate protocol and its method -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch.


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {


// test if our control subview is on-screen


if (self.controlSubview.superview != nil) {


if ([touch.view isDescendantOfView:self.controlSubview]) {


// we touched our control surface


return NO; // ignore the touch


}


}


return YES;


 


// handle the touch


 


}

or


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {


if ([touch.view isKindOfClass:[UIButton class]]){


return FALSE;


}


return TRUE;


}


 


No Comments


How to flip UIImage
UIImage* sourceImage = [UIImage imageNamed:@"whatever.png"]; 
UIImage* flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage scale:1.0 orientation: UIImageOrientationUpMirrored];
Constants:

UIImageOrientation

Specifies the possible orientations of an image.

typedef enum {
   UIImageOrientationUp,
   UIImageOrientationDown,   // 180 deg rotation
   UIImageOrientationLeft,   // 90 deg CCW
   UIImageOrientationRight,   // 90 deg CW
   UIImageOrientationUpMirrored,    // as above but image mirrored along
   // other axis. horizontal flip
   UIImageOrientationDownMirrored,  // horizontal flip
   UIImageOrientationLeftMirrored,  // vertical flip
   UIImageOrientationRightMirrored, // vertical flip
} UIImageOrientation;
Read More at ios developer reference

, , ,

No Comments


How to debug memory leak in IOS

 

http://www.raywenderlich.com/2696/how-to-debug-memory-leaks-with-xcode-and-instruments-tutorial

No Comments


How to convert NSString to BOOL, Int, Float, Double, Long

  • Converting NSString to Bool

[NSString_Instance boolValue];

  • Converting NSString to Integer

[NSString_Instance intValue];

or

[NSString_Instance integerValue];

  • Converting NSString to Float

[NSString_Instance floatValue];

  • Converting NSString to Double

[NSString_Instance doubleValue];

  • Converting NSString to Long

[NSString_Instance longLongValue];

, , , ,

No Comments


How to check if file is exists in iOS

use the NSFileManager class.

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:@”filename”];

, , ,

3 Comments



SetPageWidth