dirs (owner)

Revisions

gist: 147887 Download_button fork
public
Public Clone URL: git://gist.github.com/147887.git
Embed All Files: show embed
date.m #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#import "Date.h"
 
@implementation Date
@synthesize datePickerView;
 
+ (void) show:(NSString*)options forWebView:(UIWebView*)webView
{
Date* date = [Date alloc];
[date show];
[date release];
}
 
// return the picker frame based on its size, positioned at the bottom of the page
- (CGRect)pickerFrameWithSize:(CGSize)size
{
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
CGRect pickerRect = CGRectMake( 0.0,
screenRect.size.height - 84.0 - size.height,
size.width,
size.height);
return pickerRect;
}
 
- (void) show {
datePickerView = [[UIDatePicker alloc] initWithFrame:CGRectZero];
datePickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
datePickerView.datePickerMode = UIDatePickerModeDate;
 
// position the picker at the bottom
CGSize pickerSize = [datePickerView sizeThatFits:CGSizeZero];
datePickerView.frame = [self pickerFrameWithSize:pickerSize];
 
// add this picker to our view controller, initially hidden
NSDate *today = [NSDate date];
datePickerView.date = today;
[self.view addSubview:datePickerView];
}
 
- (void) dealloc {
[super dealloc];
}
 
@end