Skip to content

Commit

Permalink
Added a sample of Safari Services Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
shu223 committed Oct 2, 2013
1 parent 2307888 commit 01ef64e
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Creating a snapshot with MKMapSnapshotOptions, MKMapSnapshotter.

![](http://f.cl.ly/items/2Q3d472D37002f063716/map_snapshot.png)

###Safari Reading List

Adding an item to the Safari Reading List with the new Safari Services framework.


##See Also

Expand Down
14 changes: 14 additions & 0 deletions iOS7Sampler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
8A7BF3BC17ED8B43004EF216 /* HUTransitionGhostAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A7BF3B617ED8B43004EF216 /* HUTransitionGhostAnimator.m */; };
8A7BF3BD17ED8B43004EF216 /* HUTransitionHorizontalLinesAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A7BF3B817ED8B43004EF216 /* HUTransitionHorizontalLinesAnimator.m */; };
8A7BF3BE17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A7BF3BA17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m */; };
8AEF0F9417FBCCF600D2B9BE /* ReadingListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AEF0F9217FBCCF600D2B9BE /* ReadingListViewController.m */; };
8AEF0F9517FBCCF600D2B9BE /* ReadingListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8AEF0F9317FBCCF600D2B9BE /* ReadingListViewController.xib */; };
8AEF0F9717FBCDDB00D2B9BE /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8AEF0F9617FBCDDB00D2B9BE /* SafariServices.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -264,13 +267,18 @@
8A7BF3B817ED8B43004EF216 /* HUTransitionHorizontalLinesAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUTransitionHorizontalLinesAnimator.m; sourceTree = "<group>"; };
8A7BF3B917ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUTransitionVerticalLinesAnimator.h; sourceTree = "<group>"; };
8A7BF3BA17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUTransitionVerticalLinesAnimator.m; sourceTree = "<group>"; };
8AEF0F9117FBCCF600D2B9BE /* ReadingListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadingListViewController.h; sourceTree = "<group>"; };
8AEF0F9217FBCCF600D2B9BE /* ReadingListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReadingListViewController.m; sourceTree = "<group>"; };
8AEF0F9317FBCCF600D2B9BE /* ReadingListViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReadingListViewController.xib; sourceTree = "<group>"; };
8AEF0F9617FBCDDB00D2B9BE /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = System/Library/Frameworks/SafariServices.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
8A7BF1BA17ED384B004EF216 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8AEF0F9717FBCDDB00D2B9BE /* SafariServices.framework in Frameworks */,
8A6DBC8017F2C352004311FE /* CoreImage.framework in Frameworks */,
8A6DBC6817F18814004311FE /* SpriteKit.framework in Frameworks */,
8A043B1B17F0D3D600DA84E9 /* MapKit.framework in Frameworks */,
Expand Down Expand Up @@ -339,6 +347,7 @@
8A7BF1BF17ED384C004EF216 /* Frameworks */ = {
isa = PBXGroup;
children = (
8AEF0F9617FBCDDB00D2B9BE /* SafariServices.framework */,
8A6DBC7F17F2C352004311FE /* CoreImage.framework */,
8A6DBC6717F18814004311FE /* SpriteKit.framework */,
8A043B1A17F0D3D600DA84E9 /* MapKit.framework */,
Expand Down Expand Up @@ -444,6 +453,9 @@
7AB9988E17F5D776003E769F /* MultipeerConnectivityViewController.h */,
7AB9988F17F5D776003E769F /* MultipeerConnectivityViewController.m */,
7AB9989017F5D776003E769F /* MultipeerConnectivityViewController.xib */,
8AEF0F9117FBCCF600D2B9BE /* ReadingListViewController.h */,
8AEF0F9217FBCCF600D2B9BE /* ReadingListViewController.m */,
8AEF0F9317FBCCF600D2B9BE /* ReadingListViewController.xib */,
);
path = SampleViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -620,6 +632,7 @@
8A6DBC7217F19718004311FE /* MapDirectionsViewController.xib in Resources */,
8A7BF36317ED5BB1004EF216 /* m7@2x.png in Resources */,
8A7BF36417ED5BB1004EF216 /* m8@2x.png in Resources */,
8AEF0F9517FBCCF600D2B9BE /* ReadingListViewController.xib in Resources */,
8A7BF37717ED5BB1004EF216 /* m27@2x.png in Resources */,
8A7BF36B17ED5BB1004EF216 /* m15@2x.png in Resources */,
8A7BF3A717ED7F5D004EF216 /* stage_6@2x.png in Resources */,
Expand Down Expand Up @@ -727,6 +740,7 @@
8A43D5DC17F187BE005E8BE8 /* SpriteKitViewController.m in Sources */,
8A7BF3BC17ED8B43004EF216 /* HUTransitionGhostAnimator.m in Sources */,
8A7BF38D17ED7897004EF216 /* SpeechSynthesisViewController.m in Sources */,
8AEF0F9417FBCCF600D2B9BE /* ReadingListViewController.m in Sources */,
8A43D5D817F12397005E8BE8 /* UIViewController+Animator.m in Sources */,
8A7BF1DA17ED384C004EF216 /* DetailViewController.m in Sources */,
8A7BF3BE17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions iOS7Sampler/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ - (void)viewDidLoad
kItemKeyDescription: @"Creating a snapshot with MKMapSnapshotOptions, MKMapSnapshotter.",
kItemKeyClassPrefix: @"MapSnapshot",
},

// Reading List
@{kItemKeyTitle: @"Safari Reading List",
kItemKeyDescription: @"Adding an item to the Safari Reading List with the new Safari Services framework.",
kItemKeyClassPrefix: @"ReadingList",
},
];
}

Expand Down
13 changes: 13 additions & 0 deletions iOS7Sampler/SampleViewControllers/ReadingListViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ReadingListViewController.h
// iOS7Sampler
//
// Created by shuichi on 10/2/13.
// Copyright (c) 2013 Shuichi Tsutsumi. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ReadingListViewController : UIViewController

@end
72 changes: 72 additions & 0 deletions iOS7Sampler/SampleViewControllers/ReadingListViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// ReadingListViewController.m
// iOS7Sampler
//
// Created by shuichi on 10/2/13.
// Copyright (c) 2013 Shuichi Tsutsumi. All rights reserved.
//

#import "ReadingListViewController.h"
#import <SafariServices/SafariServices.h>


@interface ReadingListViewController ()

@end


@implementation ReadingListViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


// =============================================================================
#pragma mark - IBAction

- (IBAction)addToReadingList {

NSURL *url = [NSURL URLWithString:@"https://github.com/shu223/iOS7-Sampler"];
NSError *err;

BOOL result = [[SSReadingList defaultReadingList] addReadingListItemWithURL:url
title:@"iOS7 Sampler"
previewText:@"Code examples for the new functions of iOS 7."
error:&err];

UIAlertView *alert = [[UIAlertView alloc] init];
[alert addButtonWithTitle:@"OK"];

if (!result) {

alert.title = @"Failed!";
alert.message = [NSString stringWithFormat:@"Error:%@", err.description];
}
else {

alert.title = @"Done!";
alert.message = @"Added to the Safari Reading List.";
}

[alert show];
}

@end
40 changes: 40 additions & 0 deletions iOS7Sampler/SampleViewControllers/ReadingListViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ReadingListViewController">
<connections>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="duM-cS-cdZ">
<rect key="frame" x="89" y="262" width="142" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Add to Reading List">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="addToReadingList" destination="-1" eventType="touchUpInside" id="qU7-Yy-RsX"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="https://github.com/shu223/iOS7-Sampler" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gWb-eC-bEN">
<rect key="frame" x="1" y="221" width="318" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>

0 comments on commit 01ef64e

Please sign in to comment.