如何设置点击Text Field不弹出键盘
1个回答
展开全部
-(IBAction)selectDate:(id)sender
{
[self backgroundTab];
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"选择", nil];
actionSheet.tag = 51;
[actionSheet showInView:self.view.window];
//[actionSheet showFromTabBar:(UITabBar *)self.tabBarController.view];
UIDatePicker *datePicker =[[[UIDatePicker alloc] init] autorelease];
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"LocaleIdentifier", @"")];
datePicker.tag = 101;
datePicker.datePickerMode = 1;
[actionSheet addSubview:datePicker];
[actionSheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (actionSheet.tag ) {
case 51:
{
UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
spdatefield.text =[formatter stringFromDate:datePicker.date];
[formatter release];
}
break;
default:
break;
}
}
注意在头文件中添加 @interface NewSpend : UIViewController
<UIActionSheetDelegate>{
{
[self backgroundTab];
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"选择", nil];
actionSheet.tag = 51;
[actionSheet showInView:self.view.window];
//[actionSheet showFromTabBar:(UITabBar *)self.tabBarController.view];
UIDatePicker *datePicker =[[[UIDatePicker alloc] init] autorelease];
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"LocaleIdentifier", @"")];
datePicker.tag = 101;
datePicker.datePickerMode = 1;
[actionSheet addSubview:datePicker];
[actionSheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (actionSheet.tag ) {
case 51:
{
UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
spdatefield.text =[formatter stringFromDate:datePicker.date];
[formatter release];
}
break;
default:
break;
}
}
注意在头文件中添加 @interface NewSpend : UIViewController
<UIActionSheetDelegate>{
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询