Skip to content

Commit

Permalink
Added UIWebView's Pagination mode sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
shu223 committed Feb 10, 2014
1 parent bdfe407 commit 2945a15
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ Performs animations using a timing curve described by the motion of a spring.
![](http://f.cl.ly/items/1S1n3w0M132q3m42430B/springanimation_r1_c1.jpg)


###Web Pagination

Pagination sample for web pages. It uses new property "paginationMode" of UIWebView.

![](http://f.cl.ly/items/2q2F0L2o2G3H2F0k0l1E/IMG_9221_r1_c1.jpg)


##See Also

###[Open source collection for Flat Design UI](http://d.hatena.ne.jp/shu223/20130617/1371606128)
Expand Down
10 changes: 10 additions & 0 deletions iOS7Sampler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
8A7BF3BE17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A7BF3BA17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m */; };
8A9C30FC18A8BCAE0060F45C /* SpringAnimationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A9C30FA18A8BCAE0060F45C /* SpringAnimationViewController.m */; };
8A9C30FD18A8BCAE0060F45C /* SpringAnimationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A9C30FB18A8BCAE0060F45C /* SpringAnimationViewController.xib */; };
8A9C310118A8C8FA0060F45C /* WebPaginationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A9C30FF18A8C8FA0060F45C /* WebPaginationViewController.m */; };
8A9C310218A8C8FA0060F45C /* WebPaginationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A9C310018A8C8FA0060F45C /* WebPaginationViewController.xib */; };
8AC907501850931C00A74F2E /* BeaconViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AC9074E1850931C00A74F2E /* BeaconViewController.m */; };
8AC907511850931C00A74F2E /* BeaconViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8AC9074F1850931C00A74F2E /* BeaconViewController.xib */; };
8AC907551850A66000A74F2E /* PulsingHaloLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AC907541850A66000A74F2E /* PulsingHaloLayer.m */; };
Expand Down Expand Up @@ -283,6 +285,9 @@
8A9C30F918A8BCAE0060F45C /* SpringAnimationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringAnimationViewController.h; sourceTree = "<group>"; };
8A9C30FA18A8BCAE0060F45C /* SpringAnimationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpringAnimationViewController.m; sourceTree = "<group>"; };
8A9C30FB18A8BCAE0060F45C /* SpringAnimationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SpringAnimationViewController.xib; sourceTree = "<group>"; };
8A9C30FE18A8C8FA0060F45C /* WebPaginationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPaginationViewController.h; sourceTree = "<group>"; };
8A9C30FF18A8C8FA0060F45C /* WebPaginationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebPaginationViewController.m; sourceTree = "<group>"; };
8A9C310018A8C8FA0060F45C /* WebPaginationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WebPaginationViewController.xib; sourceTree = "<group>"; };
8AC9074D1850931C00A74F2E /* BeaconViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeaconViewController.h; sourceTree = "<group>"; };
8AC9074E1850931C00A74F2E /* BeaconViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeaconViewController.m; sourceTree = "<group>"; };
8AC9074F1850931C00A74F2E /* BeaconViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BeaconViewController.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -509,6 +514,9 @@
8A9C30F918A8BCAE0060F45C /* SpringAnimationViewController.h */,
8A9C30FA18A8BCAE0060F45C /* SpringAnimationViewController.m */,
8A9C30FB18A8BCAE0060F45C /* SpringAnimationViewController.xib */,
8A9C30FE18A8C8FA0060F45C /* WebPaginationViewController.h */,
8A9C30FF18A8C8FA0060F45C /* WebPaginationViewController.m */,
8A9C310018A8C8FA0060F45C /* WebPaginationViewController.xib */,
);
path = SampleViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -740,6 +748,7 @@
8A7BF36C17ED5BB1004EF216 /* m16@2x.png in Resources */,
8A7BF37617ED5BB1004EF216 /* m26@2x.png in Resources */,
8AEFF7421810083A004182BD /* FontsViewController.xib in Resources */,
8A9C310218A8C8FA0060F45C /* WebPaginationViewController.xib in Resources */,
8A7BF37217ED5BB1004EF216 /* m22@2x.png in Resources */,
8A7BF36517ED5BB1004EF216 /* m9@2x.png in Resources */,
8A7BF38017ED5BB1004EF216 /* m36@2x.png in Resources */,
Expand Down Expand Up @@ -814,6 +823,7 @@
8A7BF1D117ED384C004EF216 /* AppDelegate.m in Sources */,
8A7BF39417ED7EF7004EF216 /* MotionEffectViewController.m in Sources */,
7AB9989117F5D776003E769F /* MultipeerConnectivityViewController.m in Sources */,
8A9C310118A8C8FA0060F45C /* WebPaginationViewController.m in Sources */,
8A43D5B117F11BCA005E8BE8 /* MapSnapshotViewController.m in Sources */,
8A7BF3BB17ED8B43004EF216 /* HUTransitionAnimator.m in Sources */,
8A6DBC7117F19718004311FE /* MapDirectionsViewController.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 @@ -144,6 +144,12 @@ - (void)viewDidLoad
kItemKeyDescription: @"Performs animations using a timing curve described by the motion of a spring.",
kItemKeyClassPrefix: @"SpringAnimation",
},

// Web Pagination
@{kItemKeyTitle: @"Web Pagination",
kItemKeyDescription: @"Pagination sample for web pages. It uses new property \"paginationMode\" of UIWebView.",
kItemKeyClassPrefix: @"WebPagination",
},
];
}

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

#import <UIKit/UIKit.h>

@interface WebPaginationViewController : UIViewController

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

#import "WebPaginationViewController.h"
#import "SVProgressHUD.h"


#define kURL @"http://d.hatena.ne.jp/shu223/touch?smartphone_view=0"


@interface WebPaginationViewController ()
<UIWebViewDelegate>
@property (nonatomic, weak) IBOutlet UIWebView *webView;
@end


@implementation WebPaginationViewController

- (void)viewDidLoad
{
[super viewDidLoad];

self.webView.delegate = self;
self.webView.scalesPageToFit = YES;
self.webView.scrollView.pagingEnabled = YES;

[SVProgressHUD showWithStatus:@"Loading..."
maskType:SVProgressHUDMaskTypeGradient];

NSURL *url = [NSURL URLWithString:kURL];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[self.webView loadRequest:request];
}

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


// =============================================================================
#pragma mark - UIWebViewDelegate

- (void)webViewDidFinishLoad:(UIWebView *)webView {

[SVProgressHUD dismiss];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

[SVProgressHUD showErrorWithStatus:error.localizedDescription];
}


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

- (IBAction)segmentChanged:(UISegmentedControl *)sender {

// Change pagination mode

switch (sender.selectedSegmentIndex) {
case 0:
default:
// default
[self.webView setPaginationMode:UIWebPaginationModeUnpaginated];
break;
case 1:
[self.webView setPaginationMode:UIWebPaginationModeTopToBottom];
break;
case 2:
[self.webView setPaginationMode:UIWebPaginationModeBottomToTop];
break;
case 3:
[self.webView setPaginationMode:UIWebPaginationModeLeftToRight];
break;
case 4:
[self.webView setPaginationMode:UIWebPaginationModeRightToLeft];
break;
}

NSLog(@"gapBetweenPages:%f", self.webView.gapBetweenPages);
NSLog(@"pagaCount:%lu", (unsigned long)self.webView.pageCount);
NSLog(@"pageLength:%f", self.webView.pageLength);
}

@end
43 changes: 43 additions & 0 deletions iOS7Sampler/SampleViewControllers/WebPaginationViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B3116" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="WebPaginationViewController">
<connections>
<outlet property="view" destination="1" id="3"/>
<outlet property="webView" destination="fdN-86-LZO" id="HQ6-aQ-3uJ"/>
</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>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fdN-86-LZO">
<rect key="frame" x="0.0" y="0.0" width="320" height="500"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</webView>
<segmentedControl opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="XP9-nj-Yhf">
<rect key="frame" x="10" y="520" width="300" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="None"/>
<segment title="T to B"/>
<segment title="B to T"/>
<segment title="L to R"/>
<segment title="R to L"/>
</segments>
<connections>
<action selector="segmentChanged:" destination="-1" eventType="valueChanged" id="QRG-JY-oiB"/>
</connections>
</segmentedControl>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>

0 comments on commit 2945a15

Please sign in to comment.