forked from shu223/iOS7-Sampler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UIWebView's Pagination mode sample.
- Loading branch information
Showing
6 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
iOS7Sampler/SampleViewControllers/WebPaginationViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
93
iOS7Sampler/SampleViewControllers/WebPaginationViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
iOS7Sampler/SampleViewControllers/WebPaginationViewController.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |