Skip to content

Instantly share code, notes, and snippets.

@jkhowland
jkhowland / PageViewControllerDataSource.m
Created February 12, 2015 09:18
PageViewControllerDataSource
- (UIViewController *)initialViewController {
ContentViewController *viewController = [ContentViewController new];
viewController.index = 0;
viewController.name = [[ContentController sharedInstance].content[0] description];
return viewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
@jkhowland
jkhowland / PresentationViewController.m
Created February 12, 2015 09:36
PresentationViewController viewDidLoad
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.dataSource = [PageViewControllerDataSource new];
self.pageViewController.dataSource = self.dataSource;
[self.pageViewController setViewControllers:@[[self.dataSource initialViewController]] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
// We need to add the pageViewController as a childViewController (so that the lifecycle methods get called together. And then we can add the main view of the pageViewController to this viewController's main view.
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
@jkhowland
jkhowland / PageControl Appearance
Created February 12, 2015 09:41
UIPageControl Appearance
UIPageControl *pageControl = [UIPageControl appearanceWhenContainedIn:[PresentationViewController class], nil];
pageControl.pageIndicatorTintColor = [UIColor darkGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor lightGrayColor];
@jkhowland
jkhowland / PresentationViewController.m
Created February 12, 2015 10:02
UIPageViewControllerDelegate methods and UIPageControl
self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40, self.view.frame.size.width, 40)];
[self.view addSubview:self.pageControl];
self.pageControl.numberOfPages = self.dataSource.pageCount;
}
#pragma mark - UIPageViewController
- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers {
@jkhowland
jkhowland / EntryController Debug
Created March 9, 2015 09:47
PrivateDB, Adding and Entry, Updating and Entry, and Removing and Entry
#pragma mark - Debugging Methods
- (void)retrieveEntriesFromCloudKit {
// Simple request to check to see what is on CloudKit
NSPredicate *truePredicate = [NSPredicate predicateWithValue:YES];
CKQuery *query = [[CKQuery alloc] initWithRecordType:EntryRecordKey predicate:truePredicate];
@jkhowland
jkhowland / SectionHeader.m
Last active August 29, 2015 14:17
SectionHeader.m
const CGFloat margin = 25;
@interface SectionHeaderView ()
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation SectionHeaderView
@jkhowland
jkhowland / AvatarView.m
Created March 15, 2015 10:02
AvatarView.m
@interface AvatarView ()
@property (nonatomic, strong) CAShapeLayer *circleLayer;
@end
@implementation AvatarView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@jkhowland
jkhowland / EventTableViewCell.m
Created March 15, 2015 10:46
EventTableViewCell.m
const CGFloat leftMargin = 50;
@interface EventTableViewCell ()
@property (nonatomic, strong) UIImageView *marker;
@property (nonatomic, strong) UILabel *eventTimeLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *locationLabel;
@property (nonatomic, strong) AvatarView *avatarView;
@jkhowland
jkhowland / deacon-sample.json
Last active August 29, 2015 14:17
A simple example of json scraped from dutytogod.lds.org
{
"deacon": {
"understand": {
"learn": {
"bullet": "<ul class=\"bullet\">\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<p>Read <a href=\"https://www.lds.org/scriptures/dc-testament/dc/11.21?lang=eng#20\" onclick=\"newWindow(this.href); return false;\" class=\"scriptureRef\">Doctrine\n\t\t\t\t\t\t\t\tand Covenants 11:21</a>. What promises does the Lord give to those who study His word?\n\t\t\t\t\t\t\tRecord your thoughts in the box below.</p>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<p>You will need a basic understanding and a testimony of gospel truths to\n\t\t\t\t\t\t\tfulfill your duties now as a priesthood holder and in the future as a full-time missionary\n\t\t\t\t\t\t\tand as a husband and father.</p>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<p>Look at the list of <a href=\"https://www.lds.org/young-men/duty-to-god/deacon/understand/act?lang=eng\" class=\"crossRef\">doctrinal topics</a>, and choose\n\t\t\t\t\t\t\tfour or more that you would like to learn about. One of th
@jkhowland
jkhowland / Push.m
Created March 25, 2015 07:08
Push Notification Steps - Sup
// If you use Parse for Push Notifications, the tutorial on their site is well written: https://www.parse.com/tutorials/ios-push-notifications
// 2 - Add Private-Key.h file and set keys
static NSString * const ParseApplicationID = @"";
static NSString * const ParseClientKey = @"";
// 3 - Register for Push from the applicationDidFinishLaunching method
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {