XCode: Displaying a UIDatePicker when user clicks on UITextbox - iphone

I have already researched this topic to death and found people posting the exact same question on a number of websites including right here in stackoverflow.
I have tried all of the suggestions but have been unable to get the UIDatePicker to actually display. It doesn't seem to matter what approach I take. I've tried using the inheritance model where I subclass the UITextBox control and override it's default methods in order to display the UIDatePicker and then I make sure that in StoryBoard I set the class of my UITextView control to be that custom class. I've tried programmatically generating the UIDatePicker and also tried dragging it onto the view in StoryBoard. When I try the programmatic approach nothing is displayed and when I try dragging it onto the StoryBoard it ALWAYS displays. When I set it's attribute to "hidden" it hides but then I can't get it to show even when I try to add code to the textboxDidBeginEditing method that should unhide it.
I've made sure to set the UITextView's inputView property equal to my UIDatePicker control.
Nothing works! I don't understand why Apple didn't just make the UIDatePicker one of the default options in the drop down list in the Attributes Inspector for the UITextView control. That would have made this so much easier.
Below is some of the code from my implementation class file.
#import "AddTasksViewController.h"
#implementation AddTasksViewController
#synthesize dueDate;
#synthesize description;
#synthesize shortTitle;
#synthesize datePicker;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.dueDate.inputView = datePicker;
}
return self;
}
- (IBAction)dueDateDidBeginEditing:(UITextView *)textField
{
[textField resignFirstResponder];
[datePicker setFrame:CGRectMake(0,200,320,120)];
[datePicker addTarget:self action:#selector(done) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];
}
Here is what my header file looks like...
#import <UIKit/UIKit.h>
#interface AddTasksViewController : UIViewController
#property (nonatomic, copy) IBOutlet UITextView *dueDate;
#property (nonatomic, copy) IBOutlet UITextView *description;
#property (nonatomic, copy) IBOutlet UITextView *shortTitle;
#property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
- (IBAction)doneEditing:(id)sender;
- (IBAction)dateChanged:(id)sender;
- (IBAction)dueDateDidBeginEditing:(UITextView *)textField;
#end
As I've already mentioned, the other approach that I took (i.e. subclassing UITextView) didn't work either. I copied the code provided here exactly as it was show. I then added the custom classes called "DateField" to my project (both the header and implementation files) and then replaced the UITextBox declaration for the dueDate with DateField in both my AddTaskViewController.h and AddTaskViewController.m files and made sure that the StoryBoard references were updated to by selecting DateField for the control's class in the Identity Inspector.
No matter what I do I cannot get the UIDatePicker to display upon clicking on the UITextView. When I set a breakpoint it does hit the dueDateDidBeginEditing method so I know that something is being triggered. The problem is that I don't understand why a subView is not being showing with the UIDatePicker.
Any help would be greatly appreciated as this seemingly straightforward task seems to be taking much, much longer than it should. I could do this sort of stuff with my eyes closed and hands tied behind my back in Java and C# yet everything is so unnecessarily complicated when it comes to Objective-C. The syntax really irritates me.
So many square brackets!!! Arghhhh!!!

Showing a UIDatePicker for the inputView of a UITextField is relatively hard compared to showing a keyboard, but relatively easy compared to the trouble you've had.
One of the first problems I noticed with your code, and it's a very common problem with those new to iOS/Mac development, is that you are attempting to set the property of an object that doesn't exist yet. Putting "self.dueDate.inputView = datePicker;" in your initWithNibName:bundle: will not work because the view has not yet loaded, and dueDate is part of your view. In objective-c an object is instantiated with alloc & init. Init is the first real method call to any object. At this point in your view controller's life the view has not been created yet. The method call where self.dueDate.inputView = datePicker; belongs is in the viewDidLoad method. It is called exactly when it sounds like it's called, and your dueDate property will be properly loaded at that point. There is no need to use a custom subclass of UITextField to display a date picking view for for your text field. Here is a very basic example of a custom input view class:
ExampleBasicDateInputView.h:
#import <UIKit/UIKit.h>
#interface ExampleBasicDateInputView : UIView
#property (strong,nonatomic) UIDatePicker *datePicker;
#end
ExampleBasicDateInputView.m:
#import "ExampleBasicDateInputView.h"
#implementation ExampleBasicDateInputView{
UITextField *_inputField; // ivar to store the textfield currently being edited
}
#synthesize datePicker = _datePicker;
// TARGET METHODS
-(void)pickerValueChanged:(UIDatePicker *)picker{
_inputField.text = self.datePicker.date.description; // set text to date description
}
-(void)viewDoubleTapped:(UITapGestureRecognizer *)tapGR{
[_inputField resignFirstResponder]; // upon double-tap dismiss picker
}
-(void)textFieldBeganEditing:(NSNotification *)note{
_inputField = note.object; // set ivar to current first responder
}
-(void)textFieldEndedEditing:(NSNotification *)note{
_inputField = nil; // the first responder ended editing CRITICAL:avoids retain cycle
}
// INITI METHODS
-(void)initializationCodeMethod{
_datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 320, 0)];// All pickers have preset height
self.bounds = _datePicker.frame; // Make our view same size as picker
[self addSubview:_datePicker];
[_datePicker addTarget:self action:#selector(pickerValueChanged:) forControlEvents:UIControlEventValueChanged]; // register to be notified when the value changes
// As an example we'll use a tap gesture recognizer to dismiss on a double-tap
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(viewDoubleTapped:)];
tapGR.numberOfTapsRequired = 2; // Limit to double-taps
[self addGestureRecognizer:tapGR];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:#selector(textFieldBeganEditing:) name:UITextFieldTextDidBeginEditingNotification object:nil]; // Ask to be informed when any textfield begins editing
[center addObserver:self selector:#selector(textFieldEndedEditing:) name:UITextFieldTextDidEndEditingNotification object:nil]; // Ask to be informed when any textfield ends editing
}
-(id)init{
if ((self = [super init])){
[self initializationCodeMethod];
}
return self;
}
-(id)initWithFrame:(CGRect)frame{
if ((self = [super initWithFrame:frame])){
[self initializationCodeMethod];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder{
if ((self = [super initWithCoder:aDecoder])){
[self initializationCodeMethod];
}
return self;
}
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidBeginEditingNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidEndEditingNotification object:nil];
}
#end
Then in view did load you would use this class like this:
ExampleBasicDateInputView *dateEntryView = [[ExampleBasicDateInputView alloc] init];
self.dueDate.inputView = datePickerView;
And as you see in the .h file we've exposed the date picker instance as a property so you can set the style. etc. like so:
dateEntryView.datePicker.datePickerMode = UIDatePickerModeDate;
Obviously this is a very basic example, but I think it shows what can be done.

I had the same issue using Storyboard. Here is how I resolved it:
Overview:
I alloc and initialize my UIDatePicker property in viewDidLoad:. I then set the inputView property of my textfield to my datepicker property.
Here is my code:
In TripViewController.h:
#property (nonatomic,strong) IBOutlet UIDatePicker *datePicker;
In TripViewController.m:
#synthesize datePicker;
...
-(void)viewDidLoad {
...
self.datePicker = [[UIDatePicker alloc]init];
[self.datePicker addTarget:self action:#selector(dateChanged) forControlEvents:UIControlEventValueChanged];
self.dateField.inputView = self.datePicker;
}
I then implement my method, dateChanged so that whenever the date picker wheel stops moving, my textfield is updated.
- (void)dateChanged
{
NSDate *date = self.datePicker.date;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateStyle:NSDateFormatterMediumStyle];
self.dateField.text = [dateFormat stringFromDate:date];
}

add UITextField's delegate in .h file to call this function when touched. then use the text field's tag value to determine what you want to do when the field is selected.
-(BOOL) textFieldShouldBeginEditing:(UITextField *) textField
{
activeTextField = textField;
if (textField.tag == 1)
{
self.datePicker.datePickerMode = UIDatePickerModeDate;
self.isDatePicker = TRUE;
self.tempTextField = textField;
[self showPicker];
return NO;
}
else if (textField.tag == 2)
{
self.datePicker.datePickerMode = UIDatePickerModeTime;
self.isDatePicker = TRUE;
self.tempTextField = textField;
[self showPicker];
return NO;
}
else if (textField.tag == 3)
{
self.isDatePicker = FALSE;
self.tempTextField = textField;
[self showPicker];
return NO;
}
else
{
self.tempTextField = textField;
return YES;
}
}

It is very easy. Defines delegate TextField (UITextFieldDelegate) in the .h in the viewDidLoad .m
myTextField.setDelegate = self;
In the same viewDidLoad associates the datePicker to myTextField.
myTextField.inputView = myDatePicker;
You can also do anime, but this is the easiest way.

Related

"Instance variable 'xxx' accessed in class method....why?

So please forgive me as I am very new to stackoverflow and to ios programming in general.
I am attempting to change the text of a button i have, replacing current text with a date string (dateStringForInput) I am passing in from another class. The button is called myTodayButton and is declared in my .h file for my class inputMilesViewController...
#property (strong, nonatomic) IBOutlet UIButton *myTodayButton;
Below is the code from my .m.
+(void) changeButtonText:(NSString*) dateStringForInput{
NSLog(#"we got to changebuttontext");
[_myTodayButton setTitle:dateStringForInput forState:UIControlStateNormal];
}
I am getting the following error "Instance variable "_myTodayButton" accessed in class method.
I understand that this is written in a class method rather than an instance method but i cant figure out how to get this change to happen. the button which prompts this call to changeButtonText is in the other class which is creating dateStringForInput.
Try like this...
For (+) instance.
+ (void) changeButtonText: Only have access to the self object.
--Step 1: Remove follwing line from header file
#property (strong, nonatomic) IBOutlet UIButton *myTodayButton;
--Step 2:
Add UIButton *myTodayButton in your class file globally..
That means declare before #implementation
Eg: In .m File
#import "Controller.h"
UIButton *myTodayButton // Add like this before #implementation
#implementation Controller
For (-) instance
- (void) changeButtonText: Only have access to the instance methods
Class methods do not have access to instance variables, that's why you're getting the error you're seeing.
You need to change the method to an instance method:
- (void)changeButtonText:(NSString *)dateStringForInput;
Then you will need to pass or obtain a reference to the instance of the class containing the method to the class calling the method.
I hope that makes sense... Add a comment if you need any clarification!
change method to an instance method instead of a class method ("-" instead of "+") create an instance of the class and then simply call it like so:
MyClass *classInstance = [[MyClass alloc] init];
[classInstance changeButtonText:#"stringText"];
Also its recommended to have weak properties for IBOutlets.
#property (nonatomic, weak) IBOutlet UIButton *myButton;
[EDIT]
Regarding your second issue with segues. Firstly do you really need a different view controller for simply displaying a UIDatePicker? I normally display them in the same UIViewController using an actionSheet, its a little work to get just right but solves this problem. I can post the code if you like?
Anyway if you want to keep your current setup I would do the following:
In the ViewController that contains the button create a new public NSString property in the .h file.
#property (nonatomic, strong) NSString *dateString;
In the View Controller that contains the date picker, after the user has selected the date override the perpareForSegue method. In here get the destination view controller (which is the one with the button and new string property created in point one above) and set the dateString.
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
MyViewController *todayViewController = (MyViewController*)[segue destinationViewController];
[todayViewController setDateString:#"valueYouRequire"];
}
In the ViewController with the button set the button's title in the viewDidLoad to be the dateString.
(void)viewDidLoad
{
[super viewDidLoad];
if (self.dateString) [self.myTodayButton setTitle:self.dateString forState:UIControlStateNormal];
}
[EDIT]
If you want to go down the actionSheet route then add this method to the ViewController with the button and play around with the frame sizes to fit your needs. The method below creates a date picker, adds it to an actionSheet and displays the actionSheet.
- (IBAction) datePressed:(id)sender {
if (!_actionSheet) {
_actionSheetFrame = CGRectMake(0, self.view.frame.size.height - 373, 320, 403);
_actionSheetBtnFrameOk = CGRectMake(20, 330, 280, 50);
_actionSheetBtnFreameCancel = CGRectMake(20, 275, 280, 50);
_pickerFrame = CGRectMake(0, 50, 320, 216);
_actionSheet = [[UIActionSheet alloc] initWithTitle:#"Select Date" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"OK", nil];
_datePicker = [[UIDatePicker alloc] init];
[_datePicker setDatePickerMode:UIDatePickerModeDate];
[_actionSheet addSubview:_datePicker];
}
[_datePicker setMaximumDate:[NSDate date]];
[_actionSheet showInView:self.view.superview];
[[[_actionSheet subviews] objectAtIndex:kActionBtnIndexOk] setFrame:_actionSheetBtnFrameOk];
[[[_actionSheet subviews] objectAtIndex:kActionBtnIndexCancel] setFrame:_actionSheetBtnFreameCancel];
[_actionSheet setFrame:_actionSheetFrame];
[_datePicker setFrame:_pickerFrame];
}
You will also have to implement the UIActionSheetDelegate method to set the button's text once the user has selected his desired date.
#pragma mark - UIActionSheet Delegate Methods
- (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self.myTodayButton setTitle:self.dateStringFromSelectedDate forState:UIControlStateNormal];
}
}

Adding NSObject to view - UIButton selector in NSObject causes crash

having a little issue in an ARC environment. Creating an NSObject that adds a view to a parent view - it's basically a 'popup class' that can handle some text and display it.
In a view controller it's instantiated..
CBHintPopup *popup = [[CBHintPopup alloc]init];
[popup showPopupWithText:#"test text" inView:self.view];
And the actual class files..
CBHintPopup.h
#interface CBHintPopup : NSObject {
}
-(void)showPopupWithText:(NSString *)text inView:(UIView *)view;
-(IBAction)closePopup;
#property (nonatomic, strong) UIView *popupView;
#property (nonatomic, strong) UIImageView *blackImageView;
#property (nonatomic, strong) UIButton *closeButton;
#end
CBHintPopup.m
#implementation CBHintPopup
#synthesize popupView,blackImageView, closeButton;
-(void)showPopupWithText:(NSString *)text inView:(UIView *)view {
//CREATE CONTAINER VIEW
self.popupView = [[UIView alloc]initWithFrame:CGRectMake((view.frame.size.width/2)-(225/2),-146,225,146)];
self.popupView.alpha = 0;
self.popupView.backgroundColor = [UIColor clearColor];
//CREATE AND ADD BACKGROUND
UIImageView *popupBackground = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,225,146)];
popupBackground.image = [UIImage imageNamed:#"hintbackground.png"];
[self.popupView addSubview:popupBackground];
//CREATE AND ADD BUTTON
self.closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.closeButton addTarget:self action:#selector(closePopup) forControlEvents:UIControlEventTouchUpInside];
[self.popupView addSubview:self.closeButton];
//CREATE AND ADD LABEL
UILabel *popupTextLabel = [[UILabel alloc]initWithFrame:CGRectMake(22,25,176,93)];
popupTextLabel.text = text;
[self.popupView addSubview:popupTextLabel];
[view addSubview:self.popupView];
}
-(void)closePopup {
NSLog(#"HI");
}
Recieving the following once closePopup is called via pressing the button ('HI' is not printed)..
-[CBHintPopup performSelector:withObject:withObject:]: message sent to deallocated instance 0x246b2fe0
I've tried retaining the button in non-ARC and a load of other methods but simply having no luck. Probably something real simple but i can't nail it. I've removed all the setting up of the labels and images etc to save some space, so ignore alpha's etc.
Any help will be much appreciated, thanks for your time.
Have you implemented the constructor for CBHintPopup,since you have called the constructor
[[CBHintPopup alloc]init];
you have to implement the constructor method like this
in .m file of CBHintPopup
-(id)init{
if(self == [super init]){
// do some initialization here
}
return self;
}
I tried your code and found the crash you mentioned. I found a solution for fixing the crash.
I declared the CBHintPopup *popup; in the viewController's interface. And changed this line
CBHintPopup *popup = [[CBHintPopup alloc]init];
to
popup = [[CBHintPopup alloc]init];
Everything worked fine for me. But I couldn't find the reason behind this. Hope this will help you.
Found a fix for it - instead of CBHintPopup being an NSObject, i simply made it a sub-class of UIView and added self to the parent view (instead of self.popupView). I wouldn't really call this a 'fix' though - more of an alternative method. Surely an NSObject can add a UIView (with a UIBUtton) to a parent view with no problems? Is this a bug?
Make sure you are retaining the object for class CBHintPopup.
I think the crash is coming because object of CBHintPopup deallocates. And hence the action method is not found.

Adding an overlay to a grid tableView

I have a tableview which each row has 4 images. I have implemented a share option which will allow the user to select multiple images. How can I add an overlay or some kind of visual effect to show that the image is selected?
I would like to add some overlay to display that an image is selected, but How would this be done without adding a new set of subview for each thumbnail? And once that is done, how would the selection of the new views be linked back to the images behind them so that they can be added to an array?
Or is there an easier way to do this?
Thanks
Depending on how you're implementing this grid view, it might make sense to track all of the selecting and deselecting at that level.
As for the overlay, the quick and dirty way is to subclass UIImageView, add a BOOL property called selected. Then you can override the setter for selected and handle showing or hiding your overlay view.
Here's how I would setup my subclass. First the interface:
#interface SelectableImageView : UIImageView
#property (nonatomic, assign, getter = isSelected) BOOL selected;
#end
and the implementation...
#interface SelectableImageView ()
#property (nonatomic, retain) UIView *overlayView;
#end
#implementation SelectableImageView
#synthesize selected;
#synthesize overlayView;
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
overlayView = [[UIView alloc] initWithFrame:frame];
overlayView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.75];
overlayView.hidden = YES;
[self addSubview:overlayView];
}
return self;
}
- (void)setSelected:(BOOL)flag
{
selected = flag;
self.overlayView.hidden = !flag;
}
- (void)dealloc
{
[overlayView release], self.overlayView = nil;
[super dealloc];
}
#end

calling a function in view controller of Utility app

I am new to objective C and I have a c++ background. I want to display a value in the label on the screen. I am calling the label value from the MainView.m. However, the label becomes blank after I click a button instead of printing a value. What is the problem? Here is the code.
MainView.h
#interface MainView : UIView {
int a;
}
-(int) vr;
#end
MainView.m
-(int) vr
{
return 100;
}
#end
MainViewController.h
#interface MainViewController : UIViewController {
IBOutlet UILabel *myLabel;
NSMutableString *displayString;
MainView *view1;
}
#property (nonatomic, retain) UILabel *myLabel;
#property (nonatomic, retain) NSMutableString *displayString;
(IBAction)showInfo;
(IBAction) pressButton:(id) sender;
#end
MainViewController.m
#synthesize myLabel, displayString;
-(IBAction) pressButton:(id) sender{
[displayString appendFormat:#"%i", view1.vr];
myLabel.text = displayString;}
- (void)viewDidLoad {
view1 = [[MainView alloc] init];
[super viewDidLoad];}
- (void)dealloc {
[view1 dealloc];
[super dealloc];}
I have not mentioned code that had been auto generated. This is enough to get the whole picture. I tried a lot to debug this thing. I believe that IBAction carries out direct command such that
myLabel.text = #"string";
but it does not invoke any method or class. Any subtle ideas? Thanks.
Few issues:
1
In MainView.h you declare -(id) vr;
And in MainView.m it returns int.
2
Maybe pressButton is not connected to the right event in Interface Builder (it is usually touch up inside).
Try to write to log in this method.
3
Maybe myLabel is not connected to the label in the Interface Builder.
Try to set tome hard-coded string to label's text property.
4
Do you initiate view1 in some place?
Can you post this piece of code too?
5
You can use [displayString appendFormat:#"%i", view1.vr];...
EDIT (due to changes in question):
6
The line [super viewDidLoad]; should be the first line inside viewDidLoad.
7
[view1 dealloc]; - never call dealloc directly on objects. Call release instead. The only place, where you can and should use dealloc is the line [super dealloc]; inside dealloc method.
8
When you format your question/answer in Stack Overflow, remember that each code line should start with at least 4 spaces (or tab). Try reformatting you question by adding 4 spaces in the beginning of each code line.
9
I think that displayString is not initiated. Add the next line in the viewDidLoad: displayString = [NSMutableString new];

display date in iphone

HI, i am developing an application, where the user needs to enter the start date and end date to view the transactions within that specified date range.
please suggest me the best way to display it in iphone.
i saw the date picker , but it occupies most of my scren..
You could have fields for the start and end date and when the user taps on one of the fields, show a detail view with the picker. Checkout how you enter a date and time in the Calendar application.
I also recently saw some application where the date picker was shown as a modal view (scrolled in from the bottom, like a keyboard). Then it only occupies the screen while the user is actually choosing a date and disappears once she is done.
Update: OK, I don't have access to a Mac at the moment and typed this all up in notepad, so it probably won't work unmodified:
First, I'd create a custom UIViewController:
#interface MyDatePickerViewController : UIViewController <UIPickerViewDelegate> {
UITextfield *textfieldBeingEdited;
UIDatePicker *datePicker;
}
#property (nonatomic, assign) UITextfield *textfieldBeingEdited; // not sure about 'assign'
#property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
- (IBAction)dismiss:(id)sender;
#end
#implementation MyDatePickerViewController
#synthesize textfieldBeingEdited;
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle {
if (self = [super initWithNibName:nibName bundle:nibBundle]) {
// do other initializations, if necessary
}
return self;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// TODO: get the date from textfieldBeingEdited and set it in the UIDatePicker
// You'd want the correct date preset when the view is animated in
self.datePicker.date = /* the date */;
}
- (void)pickerView:(UIPickerView *)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component {
NSDate *date = self.datePicker.date;
// TODO: format the date
NSString *formattedDate = ...;
// update the text field
textfieldBeingEdited.text = formattedDate;
}
- (IBAction)dismiss:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
#end
When the user taps on one of your date fields, you'd create a UIViewController and show it as a modal view:
UIViewController *datePickerViewController = [[MyDatePickerViewController alloc]
initWithNibName:#"nib name goes here" bundle:nil];
datePickerViewController.textfieldBeingEdited = /*the field with the start date or end date*/;
[self presentModalViewController:datePickerViewController animated:YES];
[datePickerViewController release];
Some comments about the nib file:
the class name of File's Owner would
be MyDatePickerViewController
add a UIDatePicker, connect it to the datePicker outlet, and set it's delegate and so on to File's Owner
add a button so the user can dismiss the view and hook it up to the -dismiss: outlet in MyDatePickerViewController
Update 2: To prevent the keyboard from displaying, I made my view controller the delegate for the UITextField. Then, I present the modal view controller in -textFieldShouldBeginEditing: and return NO. Returning NO stops the keyboard from showing:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
MyDatePickerViewController *modal = [[MyDatePickerViewController alloc] initWithNibName:nil bundle:nil];
modal.textfieldBeingEdited = self.dateField;
[self presentModalViewController:modal animated:YES];
[modal release];
return NO;
}
Visit the HIG and see what it has to say. iPhone HIG DOC