Skip to content
This repository was archived by the owner on Jan 25, 2018. It is now read-only.

Commit b25ca77

Browse files
committed
Updated custom text view code for iOS 7
1 parent 0f90b6f commit b25ca77

31 files changed

+1266
-991
lines changed

AccessibilityReadingContent/ReadingContent.xcodeproj/project.pbxproj

+347
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "4"
4+
version = "2.0">
5+
</Bucket>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//
2-
// BPXLAppDelegate.h
3-
// AccessibleCoreText
2+
// AXAppDelegate.h
3+
// ReadingContent
44
//
5-
// Created by Doug Russell on 3/22/12.
6-
// Copyright (c) 2012 Black Pixel. All rights reserved.
7-
//
5+
// Created by Doug Russell on 9/12/13.
6+
// Copyright (c) 2013 Doug Russell. All rights reserved.
7+
//
88
// Licensed under the Apache License, Version 2.0 (the "License");
99
// you may not use this file except in compliance with the License.
1010
// You may obtain a copy of the License at
@@ -16,12 +16,12 @@
1616
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717
// See the License for the specific language governing permissions and
1818
// limitations under the License.
19-
//
19+
//
2020

2121
#import <UIKit/UIKit.h>
2222

23-
@interface BPXLAppDelegate : UIResponder <UIApplicationDelegate>
23+
@interface AXAppDelegate : UIResponder <UIApplicationDelegate>
2424

25-
@property (nonatomic) UIWindow *window;
25+
@property (strong, nonatomic) UIWindow *window;
2626

2727
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// AXAppDelegate.m
3+
// ReadingContent
4+
//
5+
// Created by Doug Russell on 9/12/13.
6+
// Copyright (c) 2013 Doug Russell. All rights reserved.
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
#import "AXAppDelegate.h"
22+
23+
@implementation AXAppDelegate
24+
25+
@end
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//
2-
// BPXLTextViewContainer.h
3-
// AccessibleCoreText
2+
// AXPagedViewController.h
3+
// ReadingContent
44
//
5-
// Created by Doug Russell on 3/22/12.
6-
// Copyright (c) 2012 Black Pixel. All rights reserved.
7-
//
5+
// Created by Doug Russell on 9/12/13.
6+
// Copyright (c) 2013 Doug Russell. All rights reserved.
7+
//
88
// Licensed under the Apache License, Version 2.0 (the "License");
99
// you may not use this file except in compliance with the License.
1010
// You may obtain a copy of the License at
@@ -16,11 +16,10 @@
1616
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717
// See the License for the specific language governing permissions and
1818
// limitations under the License.
19-
//
19+
//
2020

2121
#import <UIKit/UIKit.h>
22-
#import "BPXLTextView.h"
2322

24-
@interface BPXLTextViewContainer : BPXLTextView
23+
@interface AXPagedViewController : UIViewController
2524

2625
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
//
2+
// AXPagedViewController.m
3+
// ReadingContent
4+
//
5+
// Created by Doug Russell on 9/12/13.
6+
// Copyright (c) 2013 Doug Russell. All rights reserved.
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
#import "AXPagedViewController.h"
22+
#import "AXTextViewController.h"
23+
24+
@interface AXPagedViewController () <UIPageViewControllerDataSource, UIPageViewControllerDelegate>
25+
@property (nonatomic) UIPageViewController *pageViewController;
26+
@property (nonatomic) NSArray *viewControllers;
27+
@end
28+
29+
@implementation AXPagedViewController
30+
31+
#pragma mark - Segue
32+
33+
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
34+
{
35+
[super prepareForSegue:segue sender:sender];
36+
37+
if ([segue.identifier isEqualToString:@"PageViewControllerSegue"])
38+
{
39+
self.pageViewController = segue.destinationViewController;
40+
41+
UIStoryboard *storyboard = self.storyboard;
42+
// Store our view controller pages
43+
self.viewControllers =
44+
@[
45+
[storyboard instantiateViewControllerWithIdentifier:@"ReadingContentTextViewController"],
46+
[storyboard instantiateViewControllerWithIdentifier:@"ReadingContentTextViewController"],
47+
[storyboard instantiateViewControllerWithIdentifier:@"ReadingContentTextViewController"],
48+
];
49+
[[self.viewControllers lastObject] setIsLastPage:YES];
50+
51+
self.pageViewController.dataSource = self;
52+
self.pageViewController.delegate = self;
53+
54+
self.pageViewController.view.backgroundColor = [UIColor lightGrayColor];
55+
56+
[self.pageViewController setViewControllers:@[self.viewControllers[0]] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];
57+
}
58+
}
59+
60+
#pragma mark - UIPageViewControllerDataSource
61+
62+
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
63+
{
64+
UIViewController *viewControllerBefore = nil;
65+
NSUInteger index = [self.viewControllers indexOfObject:viewController];
66+
if (index != NSNotFound)
67+
{
68+
index--;
69+
if (index != NSUIntegerMax)
70+
{
71+
viewControllerBefore = self.viewControllers[index];
72+
}
73+
}
74+
return viewControllerBefore;
75+
}
76+
77+
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
78+
{
79+
UIViewController *viewControllerAfter = nil;
80+
NSUInteger index = [self.viewControllers indexOfObject:viewController];
81+
if (index != NSNotFound)
82+
{
83+
index++;
84+
if (index != [self.viewControllers count])
85+
{
86+
viewControllerAfter = self.viewControllers[index];
87+
}
88+
}
89+
return viewControllerAfter;
90+
}
91+
92+
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
93+
{
94+
return (NSInteger)[self.viewControllers count];
95+
}
96+
97+
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
98+
{
99+
if (self.viewControllers && [self.pageViewController.viewControllers count])
100+
{
101+
NSUInteger index = [self.viewControllers indexOfObject:self.pageViewController.viewControllers[0]];
102+
if (index != NSNotFound)
103+
{
104+
return index;
105+
}
106+
}
107+
return 0;
108+
}
109+
110+
- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction
111+
{
112+
BOOL handled = NO;
113+
if (self.viewControllers && [self.pageViewController.viewControllers count])
114+
{
115+
NSUInteger index = [self.viewControllers indexOfObject:self.pageViewController.viewControllers[0]];
116+
if (index != NSNotFound)
117+
{
118+
UIPageViewControllerNavigationDirection navDirection;
119+
switch (direction) {
120+
case UIAccessibilityScrollDirectionLeft:
121+
case UIAccessibilityScrollDirectionNext:
122+
index++;
123+
if (index != [self.viewControllers count])
124+
{
125+
handled = YES;
126+
}
127+
navDirection = UIPageViewControllerNavigationDirectionForward;
128+
break;
129+
case UIAccessibilityScrollDirectionRight:
130+
case UIAccessibilityScrollDirectionPrevious:
131+
index--;
132+
if (index != NSUIntegerMax)
133+
{
134+
handled = YES;
135+
}
136+
navDirection = UIPageViewControllerNavigationDirectionReverse;
137+
break;
138+
default:
139+
break;
140+
}
141+
if (handled)
142+
{
143+
[self.pageViewController setViewControllers:@[self.viewControllers[index]] direction:navDirection animated:YES completion:^(BOOL finished) {
144+
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, nil);
145+
}];
146+
}
147+
}
148+
}
149+
return handled;
150+
}
151+
152+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// AXTextContainerView.h
3+
// ReadingContent
4+
//
5+
// Created by Doug Russell on 9/12/13.
6+
// Copyright (c) 2013 Doug Russell. All rights reserved.
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
#import "AXTextView.h"
22+
23+
@interface AXTextContainerView : AXTextView
24+
25+
@end

0 commit comments

Comments
 (0)