Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implemented standard table controls (add and delete) on the presentat…

…ion list
  • Loading branch information...
commit 05d18eea030a08cf700c9e9f958112759be5c061 1 parent b53a913
@schlu schlu authored
View
3  Classes/RootController.h
@@ -13,6 +13,9 @@
NSMutableArray *list;
}
+-(IBAction)addPresentation;
+-(IBAction)editPresentation;
+-(void)doneEditing;
-(void) setupList;
@property (nonatomic, assign) IBOutlet UISplitViewController *splitViewController;
View
59 Classes/RootController.m
@@ -50,6 +50,22 @@ -(void) setupList {
}
}
+-(IBAction)addPresentation {
+ NewFormController *newFormController = [[NewFormController alloc] initWithNibName:@"NewFormController" bundle:nil];
+ NSArray *viewControllers = [NSArray arrayWithObjects:self.navigationController, newFormController, nil];
+ self.splitViewController.viewControllers = viewControllers;
+ [newFormController release];
+}
+
+-(IBAction)editPresentation {
+ self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneEditing)] autorelease];
+ [(UITableView *)self.view setEditing:YES animated:YES];
+}
+
+-(void)doneEditing {
+ self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editPresentation)] autorelease];
+ [(UITableView *)self.view setEditing:NO animated:YES];
+}
#pragma mark -
#pragma mark Rotation support
@@ -95,6 +111,29 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(
return cell;
}
+- (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
+ return NO;
+}
+
+#pragma mark -
+#pragma mark TableView Delete Support
+- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
+ ShowOffPadAppDelegate *delegate = (ShowOffPadAppDelegate*)[[UIApplication sharedApplication] delegate];
+ for (NSIndexPath *indexPath in indexPaths) {
+ [delegate deletePresentation:[list objectAtIndex:indexPath.row]];
+ }
+ [self setupList];
+ [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:animation];
+}
+
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+ // Delete the row from the data source
+ [self deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
+ }
+}
#pragma mark -
#pragma mark Table view selection
@@ -106,25 +145,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
Create and configure a new detail view controller appropriate for the selection.
*/
NSUInteger row = indexPath.row;
-
- if (row == 0) {
- /* We may one day want to show info on a preso, so we'll need to get back */
-
- NewFormController *newFormController = [[NewFormController alloc] initWithNibName:@"NewFormController" bundle:nil];
- NSArray *viewControllers = [NSArray arrayWithObjects:self.navigationController, newFormController, nil];
- self.splitViewController.viewControllers = viewControllers;
- [newFormController release];
- } else {
- /* For now just switch to the presentation */
- // Update the split view controller's view controllers array.
- //NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
- //splitViewController.viewControllers = viewControllers;
- //[viewControllers release];
-
- ShowOffPadAppDelegate *delegate = (ShowOffPadAppDelegate*)[[UIApplication sharedApplication] delegate];
- [delegate showPresentation:[list objectAtIndex:indexPath.row-1]];
- }
+ ShowOffPadAppDelegate *delegate = (ShowOffPadAppDelegate*)[[UIApplication sharedApplication] delegate];
+ [delegate showPresentation:[list objectAtIndex:indexPath.row-1]];
}
View
1  Classes/ShowOffPadAppDelegate.h
@@ -26,6 +26,7 @@
-(void)screenDidDisconnect:(NSNotification *)notification;
- (void)showPresentation:(NSString *)directory;
- (void)dismisPresentation;
+- (BOOL)deletePresentation:(NSString *)directory;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UIWindow *extWindow;
View
19 Classes/ShowOffPadAppDelegate.m
@@ -83,6 +83,25 @@ - (void)dismisPresentation {
[self.viewController.view removeFromSuperview];
}
+- (BOOL)deletePresentation:(NSString *)directory {
+ NSArray *paths;
+ NSString *presoPath = @"";
+
+ paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ presoPath = [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"showoff"] stringByAppendingPathComponent:directory];
+
+ BOOL isDir;
+ NSFileManager *fm = [NSFileManager defaultManager];
+ if ([fm fileExistsAtPath:presoPath isDirectory:&isDir] && isDir) {
+ NSError *error;
+ [fm removeItemAtPath:presoPath error:&error];
+ if (error) {
+ return NO;
+ }
+ }
+ return YES;
+}
+
- (NSString *) ensurePresoPath {
NSArray *paths;
NSString *presoPath = @"";
View
85 MainWindow.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="3"/>
+ <integer value="6"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -90,7 +90,19 @@
<object class="IBUITableViewController" id="219327980">
<object class="IBUINavigationItem" key="IBUINavigationItem" id="791815874">
<reference key="IBUINavigationBar"/>
- <string key="IBUITitle">Root View Controller</string>
+ <string key="IBUITitle">Presentations</string>
+ <object class="IBUIBarButtonItem" key="IBUILeftBarButtonItem" id="58470414">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIStyle">1</int>
+ <reference key="IBUINavigationItem" ref="791815874"/>
+ <int key="IBUISystemItemIdentifier">2</int>
+ </object>
+ <object class="IBUIBarButtonItem" key="IBUIRightBarButtonItem" id="742217273">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIStyle">1</int>
+ <reference key="IBUINavigationItem" ref="791815874"/>
+ <int key="IBUISystemItemIdentifier">4</int>
+ </object>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<reference key="IBUIParentViewController" ref="945458882"/>
@@ -162,6 +174,22 @@
</object>
<int key="connectionID">19</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">addPresentation</string>
+ <reference key="source" ref="742217273"/>
+ <reference key="destination" ref="219327980"/>
+ </object>
+ <int key="connectionID">22</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">editPresentation</string>
+ <reference key="source" ref="58470414"/>
+ <reference key="destination" ref="219327980"/>
+ </object>
+ <int key="connectionID">23</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -230,6 +258,11 @@
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="791815874"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="742217273"/>
+ <reference ref="58470414"/>
+ </object>
<reference key="parent" ref="219327980"/>
</object>
<object class="IBObjectRecord">
@@ -237,6 +270,16 @@
<reference key="object" ref="438560707"/>
<reference key="parent" ref="0"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">20</int>
+ <reference key="object" ref="742217273"/>
+ <reference key="parent" ref="791815874"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">21</int>
+ <reference key="object" ref="58470414"/>
+ <reference key="parent" ref="791815874"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -249,6 +292,8 @@
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>2.UIWindow.visibleAtLaunch</string>
+ <string>20.IBPluginDependency</string>
+ <string>21.IBPluginDependency</string>
<string>3.IBEditorWindowLastContentRect</string>
<string>3.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
@@ -275,6 +320,8 @@
<string>{{1001, 236}, {768, 1024}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<integer value="1"/>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{855, 340}, {1024, 768}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -304,7 +351,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">19</int>
+ <int key="maxID">23</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -391,6 +438,38 @@
<object class="IBPartialClassDescription">
<string key="className">RootController</string>
<string key="superclassName">UITableViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addPresentation</string>
+ <string>editPresentation</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addPresentation</string>
+ <string>editPresentation</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">addPresentation</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">editPresentation</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
+ </object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">splitViewController</string>
<string key="NS.object.0">UISplitViewController</string>
Please sign in to comment.
Something went wrong with that request. Please try again.