Skip to content

Commit

Permalink
Add StaticTable project to show storyboard implementation of static t…
Browse files Browse the repository at this point in the history
…able views
  • Loading branch information
kharrison committed May 7, 2012
1 parent 8c1b318 commit 8a097ab
Show file tree
Hide file tree
Showing 23 changed files with 1,763 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

See http://useyourloaf.com for details

This README last updated: 23-April-2012
This README last updated: 07-May-2012
=======================================================================

+ INDEX
Expand All @@ -12,6 +12,7 @@
AlertView - Demo iOS 5 changes to UIAlertView
MasterSlide - Implementing a mail app style split view controller
NibCollection - Example use of IBOutletCollection
StaticTable - Using a storyboard to implement static table views
SyncMe - Example use of iCloud Key-value Storage
TaskTimer - Example of UIAccessibility Support
TCNibLoad - Example use of UINib class
Expand Down
42 changes: 42 additions & 0 deletions StaticTable/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
StaticTable

Version 1.0 7-May-2012 Initial version

---

The StaticTable App is an example of how to implement static table views by adding a storyboard to an existing App. It is based on the tabbed application Xcode template which provides a tabbed bar controller containing two Nib based views controllers. In this example the second view controller is replaced by a storyboard implementing a view hierarchy composed of static table views.

A full explanation of this example App can be found in the following blog post:

[Static Table Views with Storyboards](http://useyourloaf.com/blog/2012/5/7/static-table-views-with-storyboards.html)


Created by Keith Harrison (see http://useyourloaf.com)

Copyright (c) 2012 Keith Harrison. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

Neither the name of Keith Harrison nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
349 changes: 349 additions & 0 deletions StaticTable/StaticTable.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

413 changes: 413 additions & 0 deletions StaticTable/StaticTable/Settings.storyboard

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions StaticTable/StaticTable/StaticTable-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.useyourloaf.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions StaticTable/StaticTable/StaticTable-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Prefix header for all source files of the 'StaticTable' target in the 'StaticTable' project
//

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
38 changes: 38 additions & 0 deletions StaticTable/StaticTable/UYLAdvancedSettingsViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// UYLAdvancedSettingsViewController.h
// StaticTable
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2012 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Keith Harrison nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#import <UIKit/UIKit.h>

@interface UYLAdvancedSettingsViewController : UITableViewController

@end
128 changes: 128 additions & 0 deletions StaticTable/StaticTable/UYLAdvancedSettingsViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
//
// UYLAdvancedSettingsViewController.m
// StaticTable
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2012 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Keith Harrison nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#import "UYLAdvancedSettingsViewController.h"
#import "UYLAppDelegate.h"

@interface UYLAdvancedSettingsViewController ()

- (IBAction)switchToggled:(UISwitch *)sender;
- (IBAction)stepperChanged:(UIStepper *)sender;

@property (nonatomic, weak) IBOutlet UISwitch *warpSwitch;
@property (nonatomic, weak) IBOutlet UISwitch *shieldsSwitch;
@property (nonatomic, weak) IBOutlet UILabel *creditsLabel;
@property (nonatomic, weak) IBOutlet UILabel *retriesLabel;
@property (nonatomic, weak) IBOutlet UIStepper *creditsStepper;
@property (nonatomic, weak) IBOutlet UIStepper *retriesStepper;

@end

@implementation UYLAdvancedSettingsViewController

@synthesize warpSwitch=_warpSwitch;
@synthesize shieldsSwitch=_shieldsSwitch;
@synthesize creditsLabel=_creditsLabel;
@synthesize retriesLabel=_retriesLabel;
@synthesize creditsStepper=_creditsStepper;
@synthesize retriesStepper=_retriesStepper;

#define TAG_WARPSWITCH 10
#define TAG_SHIELDSSWITCH 20
#define TAG_CREDITSSTEPPER 30
#define TAG_RETRIESSTEPPER 40

#pragma mark -
#pragma mark === UIViewController ===
#pragma mark -

- (void)viewDidLoad
{
[super viewDidLoad];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

self.warpSwitch.on = [defaults boolForKey:kUYLSettingsWarpDriveKey];
self.shieldsSwitch.on = [defaults boolForKey:kUYLSettingsShieldsKey];

self.creditsStepper.value = [defaults doubleForKey:kUYLSettingsCreditsKey];
self.creditsLabel.text = [NSString stringWithFormat:@"%1.0f", self.creditsStepper.value];

self.retriesStepper.value = [defaults doubleForKey:kUYLSettingsRetriesKey];
self.retriesLabel.text = [NSString stringWithFormat:@"%1.0f", self.retriesStepper.value];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

#pragma mark -
#pragma mark === Actions ===
#pragma mark -

- (IBAction)switchToggled:(UISwitch *)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

switch (sender.tag)
{
case TAG_WARPSWITCH:
[defaults setBool:sender.on forKey:kUYLSettingsWarpDriveKey];
break;

case TAG_SHIELDSSWITCH:
[defaults setBool:sender.on forKey:kUYLSettingsShieldsKey];
break;
}
}

- (IBAction)stepperChanged:(UIStepper *)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

switch (sender.tag)
{
case TAG_CREDITSSTEPPER:
[defaults setDouble:sender.value forKey:kUYLSettingsCreditsKey];
self.creditsLabel.text = [NSString stringWithFormat:@"%1.0f", sender.value];
break;

case TAG_RETRIESSTEPPER:
[defaults setDouble:sender.value forKey:kUYLSettingsRetriesKey];
self.retriesLabel.text = [NSString stringWithFormat:@"%1.0f", sender.value];
break;
}
}

@end
48 changes: 48 additions & 0 deletions StaticTable/StaticTable/UYLAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// UYLAppDelegate.h
// StaticTable
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2012 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// Neither the name of Keith Harrison nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#import <UIKit/UIKit.h>

@interface UYLAppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;

extern NSString *kUYLSettingsSpeedKey;
extern NSString *kUYLSettingsVolumeKey;
extern NSString *kUYLSettingsWarpDriveKey;
extern NSString *kUYLSettingsShieldsKey;
extern NSString *kUYLSettingsCreditsKey;
extern NSString *kUYLSettingsRetriesKey;

@end
Loading

0 comments on commit 8a097ab

Please sign in to comment.