forked from kharrison/CodeExamples
-
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.
Add StaticTable project to show storyboard implementation of static t…
…able views
- Loading branch information
Showing
23 changed files
with
1,763 additions
and
1 deletion.
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
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. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,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> |
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,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
38
StaticTable/StaticTable/UYLAdvancedSettingsViewController.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,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
128
StaticTable/StaticTable/UYLAdvancedSettingsViewController.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,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 |
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,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 |
Oops, something went wrong.