Skip to content

Commit 16c900f

Browse files
committed
Modified DialogSample
1 parent ece35c9 commit 16c900f

6 files changed

+139
-46
lines changed

DialogSample/Classes/CustomDialogViewController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
UILabel* label_;
1919
UIButton* button_;
20+
21+
BOOL enabled_;
2022
}
2123

2224
@property (nonatomic, copy) NSString* labelText;
@@ -28,4 +30,6 @@
2830

2931
-(IBAction)touchedButton:(id)sender;
3032

33+
- (void)setEnabled:(BOOL)enabled;
34+
3135
@end

DialogSample/Classes/CustomDialogViewController.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import "CustomDialogViewController.h"
1010

11+
#define ANIMATION_DURATION 0.2
1112

1213
@implementation CustomDialogViewController
1314
@synthesize buttonTitle = buttonTitle_;
@@ -53,4 +54,27 @@ -(IBAction)touchedButton:(id)sender
5354
[self.delegate touchedButton:sender];
5455
}
5556

57+
58+
#pragma mark -
59+
#pragma mark Change behavior
60+
- (void)setEnabled:(BOOL)enabled
61+
{
62+
if (enabled_ == enabled) {
63+
return;
64+
}
65+
66+
enabled_ = enabled;
67+
self.button.enabled = enabled;
68+
69+
CGRect frame = self.label.frame;
70+
71+
if (enabled) {
72+
frame.origin.y -= frame.size.height;
73+
} else {
74+
frame.origin.y += frame.size.height;
75+
}
76+
[UIView animateWithDuration:ANIMATION_DURATION
77+
animations:^{self.label.frame = frame;}];
78+
}
79+
5680
@end

DialogSample/Classes/DialogSampleViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
@property (nonatomic, retain) IBOutlet UIButton *button;
2424

2525
- (IBAction)openDialog:(id)sender;
26+
- (IBAction)openLabel:(id)sender;
2627

2728
@end
2829

DialogSample/Classes/DialogSampleViewController.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ - (IBAction)openDialog:(id)sender
8080
{
8181

8282
if (opened) {
83+
[self.dialogViewController setEnabled:NO];
8384
[self dismissDialogViewController:self.dialogViewController
8485
animated:YES];
8586
} else {
@@ -102,4 +103,10 @@ -(void)touchedButton:(id)sender
102103
[alert show];
103104
}
104105

106+
- (IBAction)openLabel:(id)sender
107+
{
108+
[self.dialogViewController setEnabled:YES];
109+
}
110+
111+
105112
@end

DialogSample/CustomDialogViewController.xib

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</object>
1313
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
1414
<bool key="EncodedWithXMLCoder">YES</bool>
15-
<integer value="5"/>
15+
<integer value="2"/>
1616
</object>
1717
<object class="NSArray" key="IBDocument.PluginDependencies">
1818
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -42,6 +42,38 @@
4242
<int key="NSvFlags">292</int>
4343
<object class="NSMutableArray" key="NSSubviews">
4444
<bool key="EncodedWithXMLCoder">YES</bool>
45+
<object class="IBUILabel" id="191818413">
46+
<reference key="NSNextResponder" ref="872163248"/>
47+
<int key="NSvFlags">292</int>
48+
<string key="NSFrame">{{0, 20}, {320, 20}}</string>
49+
<reference key="NSSuperview" ref="872163248"/>
50+
<object class="NSColor" key="IBUIBackgroundColor">
51+
<int key="NSColorSpace">1</int>
52+
<bytes key="NSRGB">MCAwIDAgMC43NQA</bytes>
53+
</object>
54+
<bool key="IBUIOpaque">NO</bool>
55+
<bool key="IBUIClipsSubviews">YES</bool>
56+
<int key="IBUIContentMode">7</int>
57+
<bool key="IBUIUserInteractionEnabled">NO</bool>
58+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
59+
<string key="IBUIText">Label</string>
60+
<object class="NSFont" key="IBUIFont">
61+
<string key="NSName">Helvetica</string>
62+
<double key="NSSize">12</double>
63+
<int key="NSfFlags">16</int>
64+
</object>
65+
<object class="NSColor" key="IBUITextColor">
66+
<int key="NSColorSpace">1</int>
67+
<bytes key="NSRGB">MSAxIDEAA</bytes>
68+
<object class="NSColorSpace" key="NSCustomColorSpace">
69+
<int key="NSID">1</int>
70+
</object>
71+
</object>
72+
<nil key="IBUIHighlightedColor"/>
73+
<int key="IBUIBaselineAdjustment">1</int>
74+
<float key="IBUIMinimumFontSize">10</float>
75+
<int key="IBUITextAlignment">1</int>
76+
</object>
4577
<object class="IBUIView" id="665004668">
4678
<reference key="NSNextResponder" ref="872163248"/>
4779
<int key="NSvFlags">274</int>
@@ -82,38 +114,6 @@
82114
<bytes key="NSWhite">MC41AA</bytes>
83115
</object>
84116
</object>
85-
<object class="IBUILabel" id="191818413">
86-
<reference key="NSNextResponder" ref="872163248"/>
87-
<int key="NSvFlags">292</int>
88-
<string key="NSFrameSize">{320, 20}</string>
89-
<reference key="NSSuperview" ref="872163248"/>
90-
<object class="NSColor" key="IBUIBackgroundColor">
91-
<int key="NSColorSpace">1</int>
92-
<bytes key="NSRGB">MCAwIDAgMC43NQA</bytes>
93-
</object>
94-
<bool key="IBUIOpaque">NO</bool>
95-
<bool key="IBUIClipsSubviews">YES</bool>
96-
<int key="IBUIContentMode">7</int>
97-
<bool key="IBUIUserInteractionEnabled">NO</bool>
98-
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
99-
<string key="IBUIText">Label</string>
100-
<object class="NSFont" key="IBUIFont">
101-
<string key="NSName">Helvetica</string>
102-
<double key="NSSize">12</double>
103-
<int key="NSfFlags">16</int>
104-
</object>
105-
<object class="NSColor" key="IBUITextColor">
106-
<int key="NSColorSpace">1</int>
107-
<bytes key="NSRGB">MSAxIDEAA</bytes>
108-
<object class="NSColorSpace" key="NSCustomColorSpace">
109-
<int key="NSID">1</int>
110-
</object>
111-
</object>
112-
<nil key="IBUIHighlightedColor"/>
113-
<int key="IBUIBaselineAdjustment">1</int>
114-
<float key="IBUIMinimumFontSize">10</float>
115-
<int key="IBUITextAlignment">1</int>
116-
</object>
117117
</object>
118118
<string key="NSFrameSize">{320, 64}</string>
119119
<reference key="NSSuperview"/>
@@ -186,9 +186,9 @@
186186
<reference key="object" ref="872163248"/>
187187
<object class="NSMutableArray" key="children">
188188
<bool key="EncodedWithXMLCoder">YES</bool>
189-
<reference ref="191818413"/>
190189
<reference ref="236009409"/>
191190
<reference ref="665004668"/>
191+
<reference ref="191818413"/>
192192
</object>
193193
<reference key="parent" ref="0"/>
194194
</object>

DialogSample/DialogSampleViewController.xib

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,45 @@
5151
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
5252
<int key="IBUIContentHorizontalAlignment">0</int>
5353
<int key="IBUIContentVerticalAlignment">0</int>
54-
<object class="NSFont" key="IBUIFont">
54+
<object class="NSFont" key="IBUIFont" id="525897407">
5555
<string key="NSName">Helvetica-Bold</string>
5656
<double key="NSSize">15</double>
5757
<int key="NSfFlags">16</int>
5858
</object>
5959
<int key="IBUIButtonType">1</int>
6060
<string key="IBUINormalTitle">Open/Close Dialog</string>
61-
<object class="NSColor" key="IBUIHighlightedTitleColor">
61+
<object class="NSColor" key="IBUIHighlightedTitleColor" id="659975892">
6262
<int key="NSColorSpace">3</int>
6363
<bytes key="NSWhite">MQA</bytes>
6464
</object>
6565
<object class="NSColor" key="IBUINormalTitleColor">
6666
<int key="NSColorSpace">1</int>
6767
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
6868
</object>
69-
<object class="NSColor" key="IBUINormalTitleShadowColor">
69+
<object class="NSColor" key="IBUINormalTitleShadowColor" id="430902151">
7070
<int key="NSColorSpace">3</int>
7171
<bytes key="NSWhite">MC41AA</bytes>
7272
</object>
7373
</object>
74+
<object class="IBUIButton" id="28655647">
75+
<reference key="NSNextResponder" ref="774585933"/>
76+
<int key="NSvFlags">292</int>
77+
<string key="NSFrame">{{81, 170}, {158, 37}}</string>
78+
<reference key="NSSuperview" ref="774585933"/>
79+
<bool key="IBUIOpaque">NO</bool>
80+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
81+
<int key="IBUIContentHorizontalAlignment">0</int>
82+
<int key="IBUIContentVerticalAlignment">0</int>
83+
<reference key="IBUIFont" ref="525897407"/>
84+
<int key="IBUIButtonType">1</int>
85+
<string key="IBUINormalTitle">Open/Close Label</string>
86+
<reference key="IBUIHighlightedTitleColor" ref="659975892"/>
87+
<object class="NSColor" key="IBUINormalTitleColor">
88+
<int key="NSColorSpace">1</int>
89+
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
90+
</object>
91+
<reference key="IBUINormalTitleShadowColor" ref="430902151"/>
92+
</object>
7493
<object class="IBUILabel" id="83387827">
7594
<reference key="NSNextResponder" ref="774585933"/>
7695
<int key="NSvFlags">292</int>
@@ -158,6 +177,15 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
158177
</object>
159178
<int key="connectionID">11</int>
160179
</object>
180+
<object class="IBConnectionRecord">
181+
<object class="IBCocoaTouchEventConnection" key="connection">
182+
<string key="label">openLabel:</string>
183+
<reference key="source" ref="28655647"/>
184+
<reference key="destination" ref="372490531"/>
185+
<int key="IBEventType">7</int>
186+
</object>
187+
<int key="connectionID">14</int>
188+
</object>
161189
</object>
162190
<object class="IBMutableOrderedSet" key="objectRecords">
163191
<object class="NSArray" key="orderedObjects">
@@ -184,8 +212,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
184212
<reference key="object" ref="774585933"/>
185213
<object class="NSMutableArray" key="children">
186214
<bool key="EncodedWithXMLCoder">YES</bool>
187-
<reference ref="292030962"/>
188215
<reference ref="83387827"/>
216+
<reference ref="292030962"/>
217+
<reference ref="28655647"/>
189218
</object>
190219
<reference key="parent" ref="0"/>
191220
</object>
@@ -199,6 +228,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
199228
<reference key="object" ref="83387827"/>
200229
<reference key="parent" ref="774585933"/>
201230
</object>
231+
<object class="IBObjectRecord">
232+
<int key="objectID">12</int>
233+
<reference key="object" ref="28655647"/>
234+
<reference key="parent" ref="774585933"/>
235+
</object>
202236
</object>
203237
</object>
204238
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -207,6 +241,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
207241
<bool key="EncodedWithXMLCoder">YES</bool>
208242
<string>-1.CustomClassName</string>
209243
<string>-2.CustomClassName</string>
244+
<string>12.IBPluginDependency</string>
210245
<string>6.IBEditorWindowLastContentRect</string>
211246
<string>6.IBPluginDependency</string>
212247
<string>8.IBPluginDependency</string>
@@ -216,7 +251,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
216251
<bool key="EncodedWithXMLCoder">YES</bool>
217252
<string>DialogSampleViewController</string>
218253
<string>UIResponder</string>
219-
<string>{{494, 376}, {320, 480}}</string>
254+
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
255+
<string>{{494, 151}, {320, 480}}</string>
220256
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
221257
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
222258
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -238,7 +274,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
238274
</object>
239275
</object>
240276
<nil key="sourceID"/>
241-
<int key="maxID">11</int>
277+
<int key="maxID">14</int>
242278
</object>
243279
<object class="IBClassDescriber" key="IBDocument.Classes">
244280
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -247,14 +283,35 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
247283
<string key="className">DialogSampleViewController</string>
248284
<string key="superclassName">UIViewController</string>
249285
<object class="NSMutableDictionary" key="actions">
250-
<string key="NS.key.0">openDialog:</string>
251-
<string key="NS.object.0">id</string>
286+
<bool key="EncodedWithXMLCoder">YES</bool>
287+
<object class="NSArray" key="dict.sortedKeys">
288+
<bool key="EncodedWithXMLCoder">YES</bool>
289+
<string>openDialog:</string>
290+
<string>openLabel:</string>
291+
</object>
292+
<object class="NSMutableArray" key="dict.values">
293+
<bool key="EncodedWithXMLCoder">YES</bool>
294+
<string>id</string>
295+
<string>id</string>
296+
</object>
252297
</object>
253298
<object class="NSMutableDictionary" key="actionInfosByName">
254-
<string key="NS.key.0">openDialog:</string>
255-
<object class="IBActionInfo" key="NS.object.0">
256-
<string key="name">openDialog:</string>
257-
<string key="candidateClassName">id</string>
299+
<bool key="EncodedWithXMLCoder">YES</bool>
300+
<object class="NSArray" key="dict.sortedKeys">
301+
<bool key="EncodedWithXMLCoder">YES</bool>
302+
<string>openDialog:</string>
303+
<string>openLabel:</string>
304+
</object>
305+
<object class="NSMutableArray" key="dict.values">
306+
<bool key="EncodedWithXMLCoder">YES</bool>
307+
<object class="IBActionInfo">
308+
<string key="name">openDialog:</string>
309+
<string key="candidateClassName">id</string>
310+
</object>
311+
<object class="IBActionInfo">
312+
<string key="name">openLabel:</string>
313+
<string key="candidateClassName">id</string>
314+
</object>
258315
</object>
259316
</object>
260317
<object class="NSMutableDictionary" key="outlets">

0 commit comments

Comments
 (0)