Dynamically getting height of UILabel according to Text return different Value for iOS 7.0 and iOS 6.1

You have to dynamically set the frame, like below: Tested on iOS 6 to iOS 12.2 Swift: let constrainedSize = CGSize(width: self.titleLable.frame.size.width, height:9999) let attributesDictionary = [NSAttributedString.Key.font: UIFont.init(name: “HelveticaNeue”, size: 11.0)] let string = NSAttributedString.init(string: “textToShow”, attributes: attributesDictionary as [NSAttributedString.Key : Any]) var requiredHeight = string.boundingRect(with: constrainedSize, options: .usesLineFragmentOrigin, context: nil) if (requiredHeight.size.width > self.titleLable.frame.size.width) … Read more

iOS 7.1 UITextView still not scrolling to cursor/caret after new line

Improved solution’s code for UITextView descendant class: #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define is_iOS7 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@”7.0″) #define is_iOS8 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@”8.0″) @implementation MyTextView { BOOL settingText; } – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTextViewDidChangeNotification:) name:UITextViewTextDidChangeNotification object:self]; } return self; } – (void)scrollToCaretInTextView:(UITextView *)textView animated:(BOOL)animated { CGRect rect … Read more

Snapshot of MKMapView in iOS7

You can use MKMapSnapshotter and grab the image from the resulting MKMapSnapshot. See the discussion of it WWDC 2013 session video, Putting Map Kit in Perspective. For example: MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init]; options.region = self.mapView.region; options.scale = [UIScreen mainScreen].scale; options.size = self.mapView.frame.size; MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options]; [snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) … Read more

Region Monitoring Glitch on iOS 7 – Multiple Notifications at the same time

I have found a fix for this strange bug. We have tested for over 1 week and so far we haven’t see the same bug again. Here is the solution:- -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{ NSLog(@”didEnterRegion”); CLLocation * lastLocation = [manager location]; BOOL doesItContainMyPoint; if(lastLocation==nil) doesItContainMyPoint = NO; else{ CLLocationCoordinate2D theLocationCoordinate = lastLocation.coordinate; CLCircularRegion * theRegion … Read more

SKPhysicsBody and [SKNode setScale:]

Using either an SKAction or the Update loop, you can create a new SKPhysicsBody with the proper scale and apply it to the object. However, by doing so, you will lose the velocity. To fix this, you can do the following: SKPhysicsBody *newBody = [SKPhysicsBody bodyWithRectangleOfSize:boxObject.size]; newBody.velocity = boxObject.physicsBody.velocity; boxObject.physicsBody = newBody;