i m trying to make a actionsheet with UIDatepicker , this action sheet is open when the button click, i want to make action sheet like popover, but that can't work
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:#"Pick Value"
delegate:self
cancelButtonTitle:#"Done"
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,180,0,0)];
[menu addSubview:pickerView];
[menu showInView:self.view.superview];
//Change the height value in your CGRect to change the size of the actinsheet
[menu setBounds:CGRectMake(0,0,400,400)];
[pickerView release];
[menu release];
problem is here that only one line Action sheet show , that not bound 400*400 what i need to do ??
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:#"Pick Value"
delegate:self
cancelButtonTitle:#"Done"
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,180,0,0)];
[menu addSubview:pickerView];
[menu showInView:self.view.superview];
[menu setFrame:CGRectMake(0,0,320,400)]; //used setFrame instread of setBounds
[pickerView release];
[menu release];
I have tried your code and setBounds changes size of action sheet in my case.
Anyway you can also try to change sheet's frame in delegate's method
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet
It'll ensure that action sheet is already created at the moment when you're trying to update the frame.
DO this on .m file
UIViewController *popoverContent = [[UIViewController alloc]init];
UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
datepiker= [[UIDatePicker alloc]init];
[datepiker setFrame:CGRectMake(0, 0, 320, 216)];
datepiker.datePickerMode=UIDatePickerModeDateAndTime;
datepiker.hidden=NO;
datepiker.minimumDate=[NSDate date];
[self.view addSubview:datepiker];
[datepiker release];
// [datepiker addTarget:self action:#selector(changedDate:) forControlEvents:UIControlEventValueChanged];
btn_add=[[UIButton alloc]initWithFrame:CGRectMake(115, 250, 100, 30)];
[btn_add setTitle:#"Add" forState:UIControlStateNormal];
[btn_add setFont:[UIFont fontWithName:#"Arial-BoldMT" size:20]];
[btn_add setBackgroundColor:[UIColor redColor]];
[btn_add addTarget:self action:#selector(AddDate:) forControlEvents:UIControlEventTouchUpInside];
[popoverView addSubview:btn_add];
btn_cancel=[[UIButton alloc]initWithFrame:CGRectMake(115, 300, 100, 30)];
[btn_cancel setTitle:#"Cancel" forState:UIControlStateNormal];
[btn_cancel setFont:[UIFont fontWithName:#"Arial-BoldMT" size:20]];
[btn_cancel setBackgroundColor:[UIColor redColor]];
[btn_cancel addTarget:self action:#selector(CancelDate:) forControlEvents:UIControlEventTouchUpInside];
[popoverView addSubview:btn_cancel];
[popoverView addSubview:datepiker];
[popoverView addSubview:btn_add];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(320,350);
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:popoverContent];
[self.popoverController presentPopoverFromRect:CGRectMake(400,-150, 320,220)
inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
[popoverView release];
[popoverContent release];
}
-(void)AddDate:(id)sender
{
}
-(void)CancelDate:(id)sender
{
[popoverController dismissPopoverAnimated:YES];
}
DO this on .h file and add UIPickerViewDelegate,UIPopoverControllerDelegate
{
UIPopoverController *popoverController;
UIDatePicker *datepiker;
UIPickerView *picker;
UIButton *btn_add;
UIButton *btn_cancel;
}
#property(nonatomic,retain)IBOutlet UIDatePicker *datepiker;
#property(nonatomic,retain)IBOutlet UIPickerView *picker;
#property(nonatomic,retain)UIPopoverController *popoverController;
#property(nonatomic,retain)UIButton *btn_add;
#property(nonatomic,retain)UIButton *btn_cancel;
-(void)AddDate:(id)sender;
-(void)CancelDate:(id)sender;
this works for me . Njoy
Related
I have a textfield. once I tap on that I want a UIPickerView to pop out and select an item from the UIPickerView and after once I am done with the selection I want to confirm the selection by tapping on an UIActionSheet which has confirm button on it.So my requirement is to have a UIActionSheet and beneath that a picker view. I am just a beginner in iOS development and I am still not familiar with the technical terminologies. So please bear with my informal way of asking questions.
Here is my block of code:
creating UIPickerView and UIActionSheet
UIActionSheet *confirmRoomSelectionAS =[[UIActionSheet alloc]initWithTitle:#"" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Done",nil];
UIPickerView *roomTypePicker=[[UIPickerView alloc]init];
[confirmRoomSelectionAS addSubview:roomTypePicker];
[confirmRoomSelectionAS showInView:self.view];
[confirmRoomSelectionAS setBounds:CGRectMake(0, 0, 320, 600)];
[roomTypePicker setFrame:CGRectMake(0, 170, 320, 216)];
[roomTypePicker setDataSource:self];
[roomTypePicker setDelegate: self];
roomTypePicker.showsSelectionIndicator = YES;
Try like this,
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[actionSheet showInView:[self.view window]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 390)];
[actionSheet addSubview:[self createToolbar:#"Test"]];
UIPickerView *picker = [[UIPickerView alloc] init];
picker.frame = CGRectMake(0, 44, 320, 162);
picker.showsSelectionIndicator = YES;
picker.dataSource = self;
picker.delegate = self;
[actionSheet addSubview:picker];
- (UIView *)createToolbar:(NSString *)titleString {
UIToolbar *inputAccessoryView = [[UIToolbar alloc] init];
inputAccessoryView.barStyle = UIBarStyleBlackOpaque;
inputAccessoryView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[inputAccessoryView sizeToFit];
CGRect frame = inputAccessoryView.frame;
frame.size.height = 44.0f;
inputAccessoryView.frame = frame;
UIBarButtonItem *doneBtn =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(done:)];
UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *cancelBtn =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:#selector(cancel:)];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 , 11.0f, 100, 21.0f)];
[titleLabel setFont:[UIFont fontWithName:#"Helvetica" size:14]];
[titleLabel setBackgroundColor:[UIColor clearColor]];
[titleLabel setTextColor:[UIColor whiteColor]];
[titleLabel setText:titleString];
[titleLabel setTextAlignment:UITextAlignmentCenter];
UIBarButtonItem *title = [[UIBarButtonItem alloc] initWithCustomView:titleLabel];
NSMutableArray *array = [NSMutableArray arrayWithObjects:cancelBtn,flexibleSpaceLeft,title,flexibleSpaceLeft, doneBtn, nil];
[inputAccessoryView setItems:array];
[doneBtn release];
[title release];
[titleLabel release];
[flexibleSpaceLeft release];
[cancelBtn release];
return [inputAccessoryView autorelease];
}
- (void)done:(id)sender {
}
- (void)cancel:(id)sender {
}
It will be like,
3 things I thought you should modify:
1) add your cancel button manually, to later better check the cancel button pressing event
UIActionSheet * confirmRoomSelectionAS = [[UIActionSheet alloc]
initWithTitle:#""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[confirmRoomSelectionAS addButtonWithTitle:#"Done"];
confirmRoomSelectionAS.cancelButtonIndex = [confirmRoomSelectionAS addButtonWithTitle: #"Cancel"];
[confirmRoomSelectionAS showInView:self.view];
2) implement your actionsheet delegate method
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == actionSheet.cancelButtonIndex) {
// cancel button pressed;
return;
}
}
3) You should declare *UIPickerView picker in your .h to later check of its selected value in the previous delegate method (also including the Done check) by adding sthing like this:
NSInteger row;
row = [picker selectedRowInComponent:0];
I want to
show a picker view (sliding up)
deactivate the background while it's visible
show (UIActionSheet) buttons at the bottom (not at the top)
It seems to me an easy solution at first since you can find code for adding a picker view to an action sheet everywhere in the web but all solutions position the buttons at top and I need to put the buttons at the bottom of the action sheet (alignment?).
Is this possible? I guess it is if I look at: Example
Regards
Jeven
EDITED (my solution based on coded dads solution)
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 0, 0, 0);
UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
UISegmentedControl *backButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:#"Back", nil]] ;
[backButton addTarget:self action:#selector(someFunction:) forControlEvents:UIControlEventValueChanged];
backButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
backButton.segmentedControlStyle = UISegmentedControlStyleBar;
[backButton addTarget:self action:#selector(btnActionCancelClicked:) forControlEvents:UIControlEventAllEvents];
backButton.frame = CGRectMake(20.0, 220.0, 280.0, 40.0);
UISegmentedControl *acceptButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:#"Accept", nil]] ;
[acceptButton addTarget:self action:#selector(anotherFunction:) forControlEvents:UIControlEventValueChanged];
acceptButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
acceptButton.segmentedControlStyle = UISegmentedControlStyleBar;
acceptButton.frame = CGRectMake(20.0, 280.0, 280.0, 40.0);
[actionSheet addSubview:pickerView];
[actionSheet addSubview:backButton];
[actionSheet addSubview:acceptButton];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setFrame:CGRectMake(0,150,320, 400)];
... then just apply iPhone 5/iphone 4 dependent view size constraints
EDITED 2:
Just another hint! Originally I wanted to use the standard Actionsheet, but didn't want to place the pickerview at the bottom. I didn't find a way how to move the buttons. Obviously it s really simple: Add UIView as subView on UIActionSheet Good to know ;)
You have 2 possibilites:
Option1: the big tweak.
ActionSheet shows the buttons with the order defined during init. So place some dummy buttons at the top and Cancel will be the only visible, all other buttons will be hidden by the pickerview. Code (warning-tweak at otherButtonTitles):
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:#"Actionsheet"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"1", #"2", #"3", #"4", nil];
UIPickerView *pickerView = [[UIPickerView alloc] init];
pickerView.delegate = self;
pickerView.dataSource = self;
[menu addSubview:pickerView];
[menu showInView:self.view];
[menu setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = 35;
pickerView.frame = pickerRect;
Option2: the selfmade
menu = [[UIActionSheet alloc] initWithTitle:#"Actionsheet"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIPickerView *pickerView = [[UIPickerView alloc] init];
pickerView.delegate = self;
pickerView.dataSource = self;
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = 35;
pickerView.frame = pickerRect;
UIButton *startbtn = [UIButton buttonWithType:UIButtonTypeCustom];
startbtn.frame = CGRectMake(80,230, 170, 73);
[startbtn setBackgroundImage:[UIImage imageNamed:#"yourbutton.png"] forState:UIControlStateNormal];
[startbtn addTarget:self action:#selector(pressedbuttonCancel:) forControlEvents:UIControlEventTouchUpInside];
[menu addSubview:pickerView];
[menu addSubview:startbtn];
[menu showInView:self.view];
[menu setFrame:CGRectMake(0,150,320, 350)];
Check that for option2 the button should be on the actionsheet unless the clicks will not be dispatched to the selector method.
- (IBAction) showCatPicker {
if (self.catList !=nil) {
self.catList=nil;
[catList release];
}
self.catList = [[NSMutableArray alloc] init];
self.actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
if(self.catPicker == nil) {
self.catPicker = [[UIPickerView alloc] initWithFrame:pickerFrame];
self.catPicker.showsSelectionIndicator = YES;
self.catPicker.dataSource = self;
self.catPicker.opaque = YES;
self.catPicker.multipleTouchEnabled = YES;
self.catPicker.userInteractionEnabled = YES;
self.catPicker.delegate = self;
}
[self.actionSheet addSubview:self.catPicker];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Select"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor colorWithRed:19.0/255 green:122.0/255 blue:53.0/255 alpha:1.0];
[closeButton addTarget:self action:#selector(dismissGenderPicker:) forControlEvents:UIControlEventValueChanged];
UISegmentedControl *cancelButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Cancel"]];
cancelButton.momentary = YES;
cancelButton.frame = CGRectMake(10, 7.0f, 50.0f, 30.0f);
cancelButton.segmentedControlStyle = UISegmentedControlStyleBar;
cancelButton.tintColor = [UIColor colorWithRed:19.0/255 green:122.0/255 blue:53.0/255 alpha:1.0];
[cancelButton addTarget:self action:#selector(cancelActionSheet) forControlEvents:UIControlEventValueChanged];
[self.actionSheet addSubview:cancelButton];
[self.actionSheet addSubview:closeButton];
[cancelButton release];
[closeButton release];
[self.actionSheet showInView:self.view];
[self.actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[catPicker reloadComponent:0];
}
You should definitely NOT use UIActionSheet to hold an UIDatePicker because this functionality is deprecated!
From the Documentation:
Subclassing Notes
UIActionSheet is not designed to be subclassed, nor should you add
views to its hierarchy. If you need to present a sheet with more
customization than provided by the UIActionSheet API, you can create
your own and present it modally with
presentViewController:animated:completion:.
and
Important: UIActionSheet is deprecated in iOS 8. (Note that
UIActionSheetDelegate is also deprecated.) To create and manage action
sheets in iOS 8 and later, instead use UIAlertController with a
preferredStyle of UIAlertControllerStyleActionSheet.
What you could very easily do is to create an UIView to hold the UIDatePicker and animate the view as appropriate. You can even add an UIToolbar to it if you need to.
Here's an example:
Create two properties:
#property (strong, nonatomic) UIDatePicker *theDatePicker;
#property (strong, nonatomic) UIView *pickerView;
Create your picker, embed it into the UIView and show:
-(void) createDatePickerAndShow {
UIToolbar *controlToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, pickerView.bounds.size.width, 44)];
[controlToolbar sizeToFit];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *setButton = [[UIBarButtonItem alloc] initWithTitle:#"Set" style:UIBarButtonItemStyleDone target:self action:#selector(dismissDateSet)];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:#"Cancel" style:UIBarButtonItemStyleBordered target:self action:#selector(cancelDateSet)];
[controlToolbar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];
[theDatePicker setFrame:CGRectMake(0, controlToolbar.frame.size.height - 15, theDatePicker.frame.size.width, theDatePicker.frame.size.height)];
if (!pickerView) {
pickerView = [[UIView alloc] initWithFrame:theDatePicker.frame];
} else {
[pickerView setHidden:NO];
}
CGFloat pickerViewYpositionHidden = self.view.frame.size.height + pickerView.frame.size.height;
CGFloat pickerViewYposition = self.view.frame.size.height - pickerView.frame.size.height;
[pickerView setFrame:CGRectMake(pickerView.frame.origin.x,
pickerViewYpositionHidden,
pickerView.frame.size.width,
pickerView.frame.size.height)];
[pickerView setBackgroundColor:[UIColor whiteColor]];
[pickerView addSubview:controlToolbar];
[pickerView addSubview:theDatePicker];
[theDatePicker setHidden:NO];
[self.view addSubview:pickerView];
[UIView animateWithDuration:0.5f
animations:^{
[pickerView setFrame:CGRectMake(pickerView.frame.origin.x,
pickerViewYposition,
pickerView.frame.size.width,
pickerView.frame.size.height)];
}
completion:nil];
}
And to dismiss the DatePicker:
-(void) cancelDateSet {
CGFloat pickerViewYpositionHidden = self.view.frame.size.height + pickerView.frame.size.height;
[UIView animateWithDuration:0.5f
animations:^{
[pickerView setFrame:CGRectMake(pickerView.frame.origin.x,
pickerViewYpositionHidden,
pickerView.frame.size.width,
pickerView.frame.size.height)];
}
completion:nil];
}
self.view.userInteractionEnabled = NO;
self.blurView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.blurView setBackgroundColor:[UIColor lightGrayColor]];
[self.blurView setAlpha:0.3];
[[[UIApplication sharedApplication] delegate].window addSubview:self.blurView];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame];
pickerView.datePickerMode = UIDatePickerModeDate;
[pickerView setBackgroundColor:[UIColor whiteColor]];
[pickerView addTarget:self action:#selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
__block CGRect frame = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height, [[UIScreen mainScreen] bounds].size.width, 220);
self.viewForPicker = [[UIView alloc] initWithFrame:frame];
[self.viewForPicker setBackgroundColor:[UIColor whiteColor]];
[self.viewForPicker addSubview:pickerView];
[[[[UIApplication sharedApplication] delegate] window] addSubview:self.viewForPicker];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
[button setTitle:#"Done" forState:UIControlStateNormal];
[button addTarget:self action:#selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(250, 15, 60, 30)];
[button.layer setCornerRadius:5.0];
[button.layer setBorderWidth:1.0];
[button.layer setBorderColor:[[IMAppStyle appColor] CGColor]];
[self.viewForPicker addSubview:button];
[self.viewForPicker.layer setCornerRadius:8.0];
float animationDuration = 0.25;
[UIView animateWithDuration:animationDuration animations:^{
frame.origin.y -= (180+40+35);
[self.viewForPicker setFrame:frame];
}];
HEllo,
can any one guide me for the following
I want to add an ActionSheet with customize image.
In ActionSheet I want to place a table view for the data.
Two buttons(cancel & done)
Thanks....
check my answer. I am using this code to display UITableView in actionsheet.
In .h file
#property (strong, nonatomic) IBOutlet UITableView *tableView;
In .m file
-(void)addTableViewInActionSheet
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, 320, 210)];
_tableView.dataSource = self;
_tableView.delegate = self;
[actionSheet addSubview:_tableView];
UISegmentedControl *doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Done"]];
doneButton.momentary = YES;
doneButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
doneButton.segmentedControlStyle = UISegmentedControlStyleBar;
doneButton.tintColor = DEFAULT_COLOR;
[doneButton addTarget:self action:#selector(doneBtnClicked:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:doneButton];
UISegmentedControl *cancelButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Cancel"]];
cancelButton.momentary = YES;
cancelButton.frame = CGRectMake(10, 7.0f, 60.0f, 30.0f);
cancelButton.segmentedControlStyle = UISegmentedControlStyleBar;
cancelButton.tintColor = [UIColor blackColor];
[cancelButton addTarget:self action:#selector(cancelBtnClicked:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:cancelButton];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
You don't need to added table in UIActionSheet just add 7 - 8 buttons in UIActionSheet and it will automatically be placed as table.
See the attached screenshot..
HI all below is the code i am using, the textField is created in .h file and when i run the code the text field doesnt respond to keyboard( no letters typed are visible) also when i click Done on keybpard it does not trigger textfieldshouldreturn method. please help!!!
UIActionSheet *aac =[[UIActionSheet alloc] initWithTitle:#"New list item" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
UIDatePicker *theDatePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0,100.0,0.0,0.0)];
self.textField=[[UITextField alloc] init];
self.textField.frame = CGRectMake(12, 45, 260, 25);
[self.textField setDelegate:self];
self.textField.textColor=[UIColor blackColor];
self.textField.backgroundColor=[UIColor whiteColor];
[textField setBorderStyle:UITextBorderStyleRoundedRect];
[textField setReturnKeyType:UIReturnKeyDone];
textField.keyboardType=UIKeyboardAppearanceDefault;
[aac addSubview:textField];
[aac addSubview:theDatePicker];
[textField release];
[theDatePicker release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Done"]];
closeButton.momentary=YES;
closeButton.frame = CGRectMake(270, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle=UISegmentedControlStyleBar;
closeButton.tintColor =[UIColor blackColor];
[closeButton addTarget:self action:#selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[aac addSubview:closeButton];
[closeButton release];
[aac showInView:self.view];
[aac setBounds:CGRectMake(0, 0, 320, 685)];
Have you tried removing the self. from before textField? If you have defined it in your header, as well as used #property, and #synthesize in your .m, you should be good. Also, make sure you have the <UITextFieldDelegate> in your interface.
I just had the same problem; My textfield did bring up the keyboard when I touched it, but no letters appeared in the textfield when tapping on the keyboard.
In my case I had been messing with the AppDelegate.m and removed the [self.window makeKeyAndVisible];. So putting it back again (in application:didFinishLaunchingWithOptions:) solved it for me.