Few Other Useful Additions to iOS7
Message UI Framework (Attach Files to Messages) :
We have always ben using "MFMessageComposeViewController" to send messages, but we weren't allowed to add images to it.
But, after iOS7, you could use :
"- (BOOL)addAttachmentData:(NSData *)attachmentData typeIdentifier:(NSString *)uti filename:(NSString *)filename;"
this API to attach images to the messages like below :
if
([MFMessageComposeViewController canSendText] && [MFMessageComposeViewController canSendAttachments] && [MFMessageComposeViewController isSupportedAttachmentUTI:(
NSString
*)kUTTypePNG]) {
MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
vc.messageComposeDelegate =
self
;
vc.recipients = @[
@"sender"
];
UIImage *myImage = [UIImage imageNamed:
@"imageName.png"
];
BOOL
attached = [vc addAttachmentData:UIImagePNGRepresentation(myImage) typeIdentifier:(
NSString
*)kUTTypePNG filename:
@"imageName.png"
];
if
(attached) {
NSLog
(
@"Attached (:"
);
}
else
{
NSLog
(
@"Not attached ):"
);
}
[
self
presentViewController:vc animated:
YES
completion:
nil
];
}
AVFoundation (Barcode Scanner) :
Before this, we were using ZXing or ZBBar to detect barcodes.But, from now onwards, "AVFoundation" comes with the built-in support for detecting the 1D and 2D barcodes
Media Player Framework (MPVolumeView – detect airplay and current airplay route) :
We used "MPVolumeView" to interact with the AirPlay systems, but it has been difficult to find as of what the user has selected.
So, iOS7 SDK got us 2 properties to do so :
@property areWirelessRoutesAvailable
@property isWirelessRouteActive
through which we could know which airplay devices are available & connected respectively.
Also, there are 2 notification that lets you know the change in the above properties :
NSString *const MPVolumeViewWirelessRoutesAvailableDidChangeNotification;
NSString *const MPVolumeViewWirelessRouteActiveDidChangeNotification
Updated :
SSReadingList :
Through the new SafariServices framework in iOS7, we are provided with class called "SSReadingList", which helps us to add items to the Reading List in Safari.Example :
NSURL *URL = [NSURL URLWithString:@"http://saru2020.blogspot.in/2013/10/three-new-useful-additions-to-ios7.html"];
[[SSReadingList defaultReadingList] addReadingListItemWithURL:URL
title:@"iOS7 Updates"
previewText:@"..."
error:nil];
NSURLComponents (NSURLUtilities) :
Example :NSURLComponents *components = [NSURLComponents componentsWithString:@"http://www.google.com"];
components.path = @"/gmail";
components.query = @"foo=bar";
NSLog(@"%@", components.scheme); // @"http"
NSLog(@"%@", [components URL]); // @"http://www.google.com/gmail?foo=bar"
NSProgress :
NSProgress *progress = [NSProgress progressWithTotalUnitCount:50];progress.completedUnitCount = 42;
NSLog(@"%@", [progress localizedDescription]); // 84% completed
CIDetectorSmile & CIDetectorEyeBlink :
The CIDetector class in CoreImage framework, which was added in iOS5, provided us the functionality of Face detection and recognition.In iOS7, few things are added to detect whether the people in photos are smiling or their eyes are closed through CIDetectorSmile & CIDetectorEyeBlink respectively.
MKDistanceFormatter :
This class provides us with utilities to convert distance into localized strings using imperial or metric units.Example :
double lat1 = @"";
double lat2 = @"";
double lon1 = @"";
double lon2 = @"";
CLLocation *location = [[CLLocation alloc] initWithLatitude:lat1 longitude:lon1];
CLLocation *portland = [[CLLocation alloc] initWithLatitude:lat2 longitude:lon2];
CLLocationDistance distance = [portland distanceFromLocation: location];
MKDistanceFormatter *formatter = [[MKDistanceFormatter alloc] init];
formatter.units = MKDistanceFormatterUnitsImperial;
NSLog(@"%@", [formatter stringFromDistance:distance]); // 535 miles
Comments