Replacement For Deprecated -Sizewithfont:Constrainedtosize:Linebreakmode: in iOS 7

Lost with the replacement for deprecated sizeWithFont: in iOS 7

You need to use sizeWithAttributes: instead.

NSDictionary *attributeDict = @{NSFontAttributeName:cCell.lblHotelResponse.font};
CGSize expectedLabelSize = [labelText sizeWithAttributes:attributeDict];

Another way is:

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:labelText attributes:@{NSFontAttributeName: cCell.lblHotelResponse.font}];
CGRect rect = [attributedString boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin context:nil];
CGSize labelSize = rect.size;

References:

  1. sizeWithAttributes:
  2. boundingRectWithSize:options:attributes:

Alternative to deprecated AudioSessionGetProperty, for iOS 7

Trying using the AVAudioSession's otherAudioPlaying property on iOS 6.0 or higher.

[[AVAudioSession sharedInstance] isOtherAudioPlaying]

Replace the deprecation sizeWithFont:minFontSIze:actualFontSize in ios 7

Use this helper method instead:

-(CGSize)frameForText:(NSString*)text sizeWithFont:(UIFont*)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode  {

NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = lineBreakMode;

NSDictionary * attributes = @{NSFontAttributeName:font,
NSParagraphStyleAttributeName:paragraphStyle
};


CGRect textRect = [text boundingRectWithSize:size
options:NSStringDrawingUsesLineFragmentOrigin
attributes:attributes
context:nil];

//Contains both width & height ... Needed: The height
return textRect.size;
}

Use like so, if you need to support both iOS 6 and iOS 7:

#ifdef __IPHONE_7_0

titleSize = [self frameForText:self.titleLabel.text sizeWithFont:self.titleLabel.font constrainedToSize:CGSizeMake(labelMaxWidth,self.titleLabel.font.lineHeight) lineBreakMode:self.titleLabel.lineBreakMode ];

subtitleSize = [self frameForText:self.subtitleLabel.text sizeWithFont:self.subtitleLabel.font constrainedToSize:CGSizeMake(labelMaxWidth,self.subtitleLabel.font.lineHeight) lineBreakMode:self.subtitleLabel.lineBreakMode];

#else


titleSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font
constrainedToSize:CGSizeMake(labelMaxWidth,self.titleLabel.font.lineHeight)
lineBreakMode:self.titleLabel.lineBreakMode];

subtitleSize = [self.subtitleLabel.text sizeWithFont:self.subtitleLabel.font
constrainedToSize:CGSizeMake(labelMaxWidth,self.subtitleLabel.font.lineHeight)
lineBreakMode:self.subtitleLabel.lineBreakMode];
#endif

SegmentedControlStyle deprecated in iOS 7 and later (8.4) | Xcode 6.4

The segmentedControlStyle property has been deprecated because in iOS 7 it has no effect.

Instances of a UISegmentedControl now only have one style, so you can remove that line entirely. If your appearance is undesirable, you'll need to tweak further to achieve the intended look.

MKPolylineView initWithPolyLine: is deprecated in iOS 7

See the documentation for initWithPolyline:. Read the Deprecation Statement which says to use an MKPolylineRenderer object instead.

GameKit GKMatchMaker inviteHandler deprecated in iOS7, what is the replacement?

It looks like the intended replacement is the GKInviteEventListener protocol. You can see a reference to it in GKLocalPlayer.h; the GKLocalPlayerListener protocol extends it.

However, there's limited documentation on this protocol (you can search for it in the documentation window of Xcode 5, but I don't see it on the web).

Given the lack of documentation, it's probably safest to continue using the deprecated method for now. You'll need to continue using it anyway for iOS6.

ios 7 initWithOverlay deprecated

Refer to the documentations of MKPolylineView and MKCircleView:

// Prefer MKPolylineRenderer
MKPolylineRenderer *polylineView = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
polylineView.lineWidth = 3;
polylineView.strokeColor = [[UIColor alloc] initWithRed:5.0/255 green:102.0/255 blue:48.0/255 alpha:1];

//Prefer MKCircleRenderer
MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
circleView.strokeColor = [UIColor blueColor];
circleView.fillColor = [[UIColor blueColor] colorWithAlphaComponent:0.4];
circleView.lineWidth = 2;

Deprecated in iOS7: AudioSessionSetProperty

You'll want to do something like

AVAudioSession *audioSession; // get your audio session somehow

BOOL success = [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
if(!success)
{
NSLog(@"error doing outputaudioportoverride - %@", [error localizedDescription]);
}

This API is available in iOS 6 & newer iOS versions.



Related Topics



Leave a reply



Submit