Showing posts with label iOS. Show all posts
Showing posts with label iOS. Show all posts

Tuesday, December 4, 2012

iOS 6's Social Network integration

First thing I want to say: Really appreciate Apple for putting efforts to embed the social sharing functions into the iOS SDK 6.0. You know what, thousands of lines of code I used to do social sharing can be totally deleted now. Wow! It can be just less than 10 lines of code now.

To bring out the Sharing Panel above, we just need to write the code:

- (IBAction) shareButtonClicked:(id)sender{
    NSString *textToShare = @"Hello World!";
    UIImage *imageToShare = [UIImage imageNamed:@"ss.jpg"];
    NSArray *activityItems = @[textToShare, imageToShare];
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                      applicationActivities:nil];
    [self presentViewController:activityVC animated:YES completion:nil];
}

UIActivityViewController is under UIKit, so we don't need to include any framework. What we did here was to supply the activitiyVC with a string and an image, and leave all the rest to UIActivityViewController.

Sometimes, we may not provide the sharing panel to user. If we just want to present user the facebook sharing, then we can simply user the following code:

- (IBAction)facebookShare:(id)sender{
    // need include social.framework
    SLComposeViewController *facebookPostVC=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    // You can have other servicetypes for Weibo, Twitter.

    [facebookPostVC setInitialText:@"Hello World!"];
    [facebookPostVC addImage:[UIImage imageNamed:@"ss.jpg"]];
    [self presentViewController:facebookPostVC animated:YES completion:nil];

}

Very similarly, very simple codes...You will get something as following directly. As I comment in the code, we can do the same way for Twitter and Weibo. To use SLComposeViewController, we need to include Social.framework

Very simple right. I love this. However, we have to realize the drawbacks. Good things don't come out without cost... Doing this way, we have no more deep link to Facebook, no need to create App on developers.facebook. So people won't see the feed comes from your App.

Friday, July 27, 2012

Size of iPhone's Photo


Device Photo Size Photo's w:d Ratio Instagram High Resolution Instagram Low Resolution
iPhone 4S 2448 x 3264 3:4 2048 x 2048 612 x 612
iPhone 4 1936 x 2592 3:4 1936 x 1936 612 x 612
iPhone 3GS 1536 x 2048 3:4 1536 x 1536 612 x 612
Recently, I need to do some research about iPhone's photoing functions. Have some figures consolidated here to share with you and also for referring back by myself.

We all know iPhone's screen size is 320 x 480 (640 x 960 for retina), and the ratio is 2:3. Physical screen's w:h ratio 2:3 and photo's w:h ratio 3:4 is close to each other, but the difference is there. If we compare these two ratios, we will find that the photo has more width. People may seldom realize the difference because Apple has done intelligent handling when you are taking the photo with the "Camera App" and when you are viewing the photo with the "Photos App".

When you use the "Camera App" to take a photo, the preview live screen has a width=320px and a height=480px-53px (the camera controls is around 53px) =427px;320:427 is about the same as 3:4. So the preview screen and the photo's w:h ratio is the same, you get exactly what you see in the live preview captured in the photo without any distortion.



Let's see what happens when you open the photo from the "Photos App". Most likely you enter the full-screen mode. Oops, how come the photo with w:d=3:4 just fits into the iPhone's screen with w:d=2:3? The secret is it doesn't really fit. When you zoom out, you will find out the full-screen photo hides small parts at left and right while fits in the height only.

When talking about iPhone photo, have to mention Instagram. Instagram is a great app with simplicity, power, fun. Instagram's photos are all square shape, no need to worry about the ratios. All images are cropped into square before processing.