Hi I am doing a custom actionsheet in my application and I've noticed a small problem.
dismissal is ok but when doing the [actionSheet showInView:self.view],
the actionsheet animation does not start from the very bottom.
it appears from a good 200 pixels from the bottom before scrolling all the way up.
is this a known issue? i will paste my code below.
when doing a dismissal, it animates very smoothly from the top to the bottom.
Thanks in advance for any help !
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
datePickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[actionSheet addSubview:datePickerView];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 480)];
Remove this line:
[actionSheet setBounds:CGRectMake(0, 0, 320, 480)];
This is the code which is working fine.:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
actionSheet.backgroundColor = [UIColor clearColor];
UIImageView *background = [[UIImageView alloc] init];
[background setBackgroundColor:[UIColor whiteColor]];
[background setFrame:CGRectMake(0,0, 345, 250)];
background.contentMode = UIViewContentModeScaleToFill;
[actionSheet addSubview:background];
UIButton *cancelButton = [UIButton buttonWithType: UIButtonTypeCustom];
cancelButton.frame = CGRectMake(5, 160, 320, 100);
[cancelButton addTarget:self action:#selector(cancelButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
cancelButton.adjustsImageWhenHighlighted = YES;
[cancelButton setTitle:#"Cancel" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor colorWithRed:21/255.0f green:117/255.0f blue:222/255.0f alpha:1.0f] forState:UIControlStateNormal];
cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter;
cancelButton.titleLabel.font = [UIFont fontWithName: #"Helvetica Neue" size: 22];
[actionSheet addSubview: cancelButton];
UIButton *airdropButton = [UIButton buttonWithType: UIButtonTypeCustom];
airdropButton.frame = CGRectMake(0,3, 100,80);
[airdropButton setImage:[UIImage imageNamed:#"airdrop.png"] forState:UIControlStateNormal];
airdropButton.adjustsImageWhenHighlighted = YES;
UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0,90,345,1)];
[line setBackgroundColor:[UIColor grayColor]];
UIButton *messageButton = [UIButton buttonWithType: UIButtonTypeCustom];
messageButton.frame = CGRectMake(10,95,80,80);
[messageButton setImage:[UIImage imageNamed:#"message.png"] forState:UIControlStateNormal];
messageButton.adjustsImageWhenHighlighted = YES;
UIButton *mailButton = [UIButton buttonWithType: UIButtonTypeCustom];
mailButton.frame = CGRectMake(80,95,100,80);
[mailButton setImage:[UIImage imageNamed:#"mail.png"] forState:UIControlStateNormal];
mailButton.adjustsImageWhenHighlighted = YES;
UIButton *twitterButton = [UIButton buttonWithType: UIButtonTypeCustom];
twitterButton.frame = CGRectMake(160,95,80,80);
[twitterButton setImage:[UIImage imageNamed:#"twitter.png"] forState:UIControlStateNormal];
twitterButton.adjustsImageWhenHighlighted = YES;
UIButton *facebookButton = [UIButton buttonWithType: UIButtonTypeCustom];
facebookButton.frame = CGRectMake(230,95,80,80);
[facebookButton setImage:[UIImage imageNamed:#"facebook.png"] forState:UIControlStateNormal];
facebookButton.adjustsImageWhenHighlighted = YES;
[actionSheet addSubview: airdropButton];
[actionSheet addSubview:line];
[actionSheet addSubview:messageButton];
[actionSheet addSubview:mailButton];
[actionSheet addSubview:facebookButton];
[actionSheet addSubview:twitterButton];
[actionSheet showInView:myProfileTable];
[actionSheet setFrame:CGRectMake(0,340,345,250)];
Look into this if you got any problem tell me.
Related
On the iPhone I like how action sheets take up the entire width of the screen and you can choose the height of it (so I can include other views). Here is my entire method that creates the action view (you probably on need the las few lines though)...
-(void)createActionView {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:#"Done",nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
UIButton *downHoleScore = [UIButton buttonWithType:UIButtonTypeCustom];
downHoleScore.frame = CGRectMake(93, 75, 35, 35);
[downHoleScore setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
downHoleScore.backgroundColor = [UIColor clearColor];
downHoleScore.tag=1;
[downHoleScore addTarget:self action:#selector(HoleScoreButtonTap:) forControlEvents:UIControlEventTouchUpInside];
[downHoleScore setBackgroundImage:[UIImage imageNamed:#"Left-Down-Arrow.png"] forState:UIControlStateNormal];
[actionSheet addSubview:downHoleScore];
UIButton *upHoleScore = [UIButton buttonWithType:UIButtonTypeCustom];
upHoleScore.frame = CGRectMake(193, 76, 35, 35);
[upHoleScore setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
upHoleScore.backgroundColor = [UIColor clearColor];
upHoleScore.tag=2;
[upHoleScore addTarget:self action:#selector(HoleScoreButtonTap:) forControlEvents:UIControlEventTouchUpInside];
[upHoleScore setBackgroundImage:[UIImage imageNamed:#"Right-Up-Arrow.png"] forState:UIControlStateNormal];
[actionSheet addSubview:upHoleScore];
golferScoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 70, 45, 45)];
golferScoreLabel.text = #"0";
golferScoreLabel.backgroundColor = [UIColor clearColor];
golferScoreLabel.font = [UIFont fontWithName:#"ChalkDuster" size: 45.0];
golferScoreLabel.textAlignment = UITextAlignmentCenter;
golferScoreLabel.shadowColor = [UIColor grayColor];
golferScoreLabel.shadowOffset = CGSizeMake(1,1);
golferScoreLabel.textColor = [UIColor whiteColor];
[actionSheet addSubview:golferScoreLabel];
CGRect pickerFrame = CGRectMake(0, 120, 0, 0);
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet showFromRect:CGRectMake(0, 0, 320, 585) inView:self.view animated:YES];
}
How would I edit this to make it look more like an action view on the iPhone?
In this code...
[actionSheet showFromRect:CGRectMake(0, 0, 320, 585) inView:self.view animated:YES];
That above is where I think I am messing up how would I make this cover the entire bottom half of the screen on the iPad?
Read the docs on UIActionSheet. On iPad, they are presented in popovers.
If you want behavior like on the iPhone, I think you'll have to write your own actionSheet-like view and animations (which is really not that hard, it just takes a little time).
Anyway, presenting actionSheets on an iPad with the full width wouldn't be very good design anyway - you probably don't want buttons that are as wide as the whole screen. I would advise you to rethink your design.
But maybe you don't really want actionSheets. Maybe you only want that nice animation, to present some content of your own like that? That's certainly doable (see above), but then you have asked the wrong question.
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
- (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..
I am new to iphone.Is it possible to keep 3 textfields, 3 labels and 2 uibuttons in an actionsheet or alertview. Kindly give information.
Thanks in advance.
You can try this as:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"\n\n\n\n\n\n\n\n\n\n" message:#"" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
UITextField *textfield1 = [[UITextField alloc] init];
textfield1.frame = CGRectMake(10.0, 30.0,260.0, 15.0);//set your frame as you required
textfield1.text=#"";
[textfield1 setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:textfield1];
[textfield2 release];
UITextField *textfield2 = [[UITextField alloc] init];
textfield2.frame = CGRectMake(10.0, 48.0,260.0, 15.0);//set your frame as you required
textfield2.text=#"";
[textfield2 setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:textfield2];
[textfield2 release];
UITextField *textfield3 = [[UITextField alloc] init];
textfield3.frame = CGRectMake(10.0, 65.0,260.0, 155.0);//set your frame as you required
textfield3.text=#"";
[textfield3 setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:textfield3];
[textfield3 release];
UIView *tempView = [[UIView alloc]initWithFrame:CGRectMake(10.0, 80.0, 260.0, 100.0)];//set your frame as you required
tempView.backgroundColor = [UIColor clearColor];
[alert addSubview:tempView];
UILabel *label1 = [[UILabel alloc]init];
label1.frame = CGRectMake(0, 5, 50, 15);//set your label frame here
label1.text = #"Enter text";
[tempView addSubView:label1];
[label1 release];
UILabel *label2 = [[UILabel alloc]init];
label2.frame = CGRectMake(0, 25, 50, 15);//set your label frame here
label2.text = #"Enter text";
[tempView addSubView:label2];
[label2 release];
UILabel *label3 = [[UILabel alloc]init];
label3.frame = CGRectMake(0, 45, 50, 15);//set your label frame here
label3.text = #"Enter text";
[tempView addSubView:label3];
[label3 release];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = //set your button frame here
[tempView addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = //set your button frame here
[tempView addSubview:button2];
[tempView release];
[alert show];
[alert release];