我正试图通过点击文字现场执行日期。 我使用的是。
但我没有获得产出。 如果有人知道如何通过点击案文点击日期。 请提供一些解决办法。
提前感谢。
我看到你的联系,找到解决办法,这样就尝试了以下法典。
#import "TextfieldwithDatepickerViewController.h"
UIActionSheet *pickerViewPopup;
@implementation TextfieldwithDatepickerViewController
- (void)textFieldDidBeginEditing:(UITextField *)aTextField{
[aTextField resignFirstResponder];
pickerViewPopup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, 0, 0)];
pickerView.datePickerMode = UIDatePickerModeDate;
pickerView.hidden = NO;
pickerView.date = [NSDate date];
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];
[barItems addObject:doneBtn];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)];
[barItems addObject:cancelBtn];
[pickerToolbar setItems:barItems animated:YES];
[pickerViewPopup addSubview:pickerToolbar];
[pickerViewPopup addSubview:pickerView];
[pickerViewPopup showInView:self.view];
[pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
}
-(void)doneButtonPressed:(id)sender{
//Do something here here with the value selected using [pickerView date] to get that value
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}
-(void)cancelButtonPressed:(id)sender{
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}
这部法典无疑有助于你,因为我操作了该法典及其工作罚款。
-(BOOL) textFieldShouldBeginEditing:(UITextField *)txtField
{
[self createDatePicker];
}
代表
您可以把日期选择放在接口建设商的另一种观点中......,并将意见置于主意之下(x = 0; y = 460)。
因此,当你的案文成为第一答复者时(例如,案文是用一些代表的方法,即:案文是实地的,......)......只是与预期立场的标语一致。
......
[UIView beginAnimations:@"some_random_name" context:nil];
//give your date picker view a new frame
[UIView setAnimationDuration:0.3f]; //or any other value
[UIView commitAnimations];
Check that you set the delegate for the textfield. If not, set like this:
textField.delegate = self;
Or in xib add connection to the delegate.
We can use inputView and inputAccessoryView of UITextField. Declare in .h file, and @synthesize in .m file.
@property (nonatomic, retain) IBOutlet UIToolbar *_accessoryView;
@property (nonatomic, retain) IBOutlet UIDatePicker *_datePickerView;
将他们与他人联系起来,以记录其所有权。 观点。
- (void)viewDidLoad
{
_dateOfBirthTextField.inputView = self._datePickerView;
_dateOfBirthTextField.inputAccessoryView = self._toolbar;
}
还写上从小卡车到白天的职能。
#pragma mark- UITextField with UIDatePicker-
- (IBAction)dateChanged:(id)sender {
UIDatePicker *picker = (UIDatePicker *)sender;
_dateOfBirthTextField.text = [NSString stringWithFormat:@"%@", picker.date];
}
- (IBAction)doneEditing:(id)sender {
[_dateOfBirthTextField resignFirstResponder];
}
Add dateChanged: IBAction on valueChanged: action of _datePicker. and doneEditing: IBAction on toolbar barbutton action.
使用以下代码:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet showInView:self.tabBarController.tabBar];
[actionSheet setFrame:CGRectMake(0, 220, 320,350)];
pickerToolbar.barStyle = UIBarStyleDefault;
[pickerToolbar sizeToFit];
pickerToolbar.barStyle = UIBarStyleBlackTranslucent;
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:[BuddyCalcAppDelegate getLocalvalue:@"Cancel"] style:UIBarButtonSystemItemCancel target:self action:@selector(cancel_clicked:)];
[barItems addObject:cancelBtn];
[cancelBtn release];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[barItems addObject:flexSpace];
[flexSpace release];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:[BuddyCalcAppDelegate getLocalvalue:@"Done"] style:UIBarButtonItemStyleDone target:self action:@selector(done_clicked:)];
[barItems addObject:doneBtn];
[doneBtn release];
[pickerToolbar setItems:barItems animated:YES];
[actionSheet addSubview:pickerToolbar];
[barItems release];
[pickerToolbar release];
UIDatePicker *datePicker=[[UIDatePicker alloc]init];
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight)
{
datePicker.frame=CGRectMake(0,32,480, 216);
[scrollView setContentOffset:CGPointMake(0, 60) animated:YES];
} else {
datePicker.frame=CGRectMake(0,44,320, 216);
}
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
[datePicker setMinuteInterval:5];
[datePicker setTag:10];
[actionSheet addSubview:datePicker];
[datePicker addTarget:self action:@selector(Result) forControlEvents:UIControlEventValueChanged];
[datePicker release];
I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...
HI, In our application i am using corelocationframework when opening application a alert for allow and dont allow.when clicking on the allow for current location we will show current location.When ...
Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...
我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......
我希望我与四舍五入的累进角进行网上讨论。
我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
I like to write bash shell scripts on my iPhone, put them in an app folder with an icon, plist, etc., so they execute like apps by tapping their icon on SpringBoard. This is not interactive like ...