Skip to content

Commit

Permalink
Refactored segmentcontrol in issues controller to be configured via I…
Browse files Browse the repository at this point in the history
…nterface Builder
  • Loading branch information
dbloete committed May 3, 2009
1 parent 4dc99ed commit c66f8ac
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Classes/IssuesController.h
Expand Up @@ -6,11 +6,13 @@
@interface IssuesController : UITableViewController {
@private
GHIssues *issues;
IBOutlet UISegmentedControl *issuesControl;
IBOutlet UITableViewCell *loadingIssuesCell;
IBOutlet UITableViewCell *noIssuesCell;
IBOutlet IssueCell *issueCell;
}

- (id)initWithIssues:(GHIssues *)theIssues;
- (IBAction)switchChanged:(id)sender;

@end
15 changes: 4 additions & 11 deletions Classes/IssuesController.m
Expand Up @@ -13,21 +13,12 @@ - (id)initWithIssues:(GHIssues *)theIssues {
}

- (void)viewDidLoad {
NSArray *segmentTextContent = [NSArray arrayWithObjects:@"Open", @"", @"Closed", nil];
UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
segmentedControl.selectedSegmentIndex = 0;
segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
[segmentedControl setWidth:1 forSegmentAtIndex:1];
[segmentedControl setEnabled:NO forSegmentAtIndex:1];
self.navigationItem.titleView = segmentedControl;
[segmentedControl release];
[super viewDidLoad];
self.navigationItem.titleView = issuesControl;
if (!issues.isLoaded) [issues loadIssues];
}

- (void) segmentAction:(id)sender {
- (IBAction)switchChanged:(id)sender {
UISegmentedControl* segCtl = sender;
[issues reloadForState:(( ( segCtl.selectedSegmentIndex == 0 ) ? @"open" : @"closed" ) )];
[self.tableView reloadData];
Expand Down Expand Up @@ -66,6 +57,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}

- (void)dealloc {
[issues removeObserver:self forKeyPath:kResourceStatusKeyPath];
[issuesControl release];
[loadingIssuesCell release];
[noIssuesCell release];
[issueCell release];
Expand Down
79 changes: 78 additions & 1 deletion IBFiles/Issues.xib
Expand Up @@ -8,6 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="21"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -172,6 +173,42 @@
<reference key="IBUIContentView" ref="582832122"/>
<string key="IBUIReuseIdentifier">LoadingIssuesCell</string>
</object>
<object class="IBUISegmentedControl" id="1002590521">
<reference key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{0, 7}, {207, 30}}</string>
<reference key="NSSuperview"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBSegmentControlStyle">2</int>
<int key="IBNumberOfSegments">2</int>
<int key="IBSelectedSegmentIndex">0</int>
<object class="NSArray" key="IBSegmentTitles">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Open</string>
<string>Closed</string>
</object>
<object class="NSMutableArray" key="IBSegmentWidths">
<bool key="EncodedWithXMLCoder">YES</bool>
<real value="0.000000e+00"/>
<real value="0.000000e+00"/>
</object>
<object class="NSMutableArray" key="IBSegmentEnabledStates">
<bool key="EncodedWithXMLCoder">YES</bool>
<boolean value="YES" id="5"/>
<reference ref="5"/>
</object>
<object class="NSMutableArray" key="IBSegmentContentOffsets">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{0, 0}</string>
<string>{0, 0}</string>
</object>
<object class="NSMutableArray" key="IBSegmentImages">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSNull" id="4"/>
<reference ref="4"/>
</object>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
Expand Down Expand Up @@ -216,6 +253,23 @@
</object>
<int key="connectionID">13</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">issuesControl</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1002590521"/>
</object>
<int key="connectionID">22</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">switchChanged:</string>
<reference key="source" ref="1002590521"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
</object>
<int key="connectionID">23</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -278,6 +332,11 @@
<reference key="object" ref="961888917"/>
<reference key="parent" ref="133000233"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">21</int>
<reference key="object" ref="1002590521"/>
<reference key="parent" ref="360949347"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -288,6 +347,8 @@
<string>-2.CustomClassName</string>
<string>10.IBPluginDependency</string>
<string>11.IBPluginDependency</string>
<string>21.IBEditorWindowLastContentRect</string>
<string>21.IBPluginDependency</string>
<string>3.IBEditorWindowLastContentRect</string>
<string>3.IBPluginDependency</string>
<string>7.IBEditorWindowLastContentRect</string>
Expand All @@ -302,6 +363,8 @@
<string>UIResponder</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{528, 705}, {207, 44}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{101, 676}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{689, 890}, {320, 50}}</string>
Expand Down Expand Up @@ -331,7 +394,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">13</int>
<int key="maxID">23</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -358,6 +421,14 @@
<string>UILabel</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/IssueCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">IssueCell</string>
<string key="superclassName">UITableViewCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
Expand All @@ -366,17 +437,23 @@
<object class="IBPartialClassDescription">
<string key="className">IssuesController</string>
<string key="superclassName">UITableViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">switchChanged:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>issueCell</string>
<string>issuesControl</string>
<string>loadingIssuesCell</string>
<string>noIssuesCell</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>IssueCell</string>
<string>UISegmentedControl</string>
<string>UITableViewCell</string>
<string>UITableViewCell</string>
</object>
Expand Down

0 comments on commit c66f8ac

Please sign in to comment.