Ios7 UITextFieldDelegate可在iOS 8上工作,但不能在iOS 7上工作
我有一个UIViewController,其中有一个UIExtField,并且符合UIExtFieldDelegate协议。当我第一次构建应用程序iOS 7时,它是最新的iOS,当我选择文本字段时,键盘会如预期的那样出现 随之而来的是iOS 8和Xcode 6。自从我第一次编写代码以来,代码没有任何变化,但奇怪的是,现在,当我在iOS 8设备上选择文本字段时,键盘会出现,而在iOS 7设备上则没有 为什么会这样?有什么想法吗 这是我的密码:Ios7 UITextFieldDelegate可在iOS 8上工作,但不能在iOS 7上工作,ios7,ios8,uitextfield,uitextfielddelegate,Ios7,Ios8,Uitextfield,Uitextfielddelegate,我有一个UIViewController,其中有一个UIExtField,并且符合UIExtFieldDelegate协议。当我第一次构建应用程序iOS 7时,它是最新的iOS,当我选择文本字段时,键盘会如预期的那样出现 随之而来的是iOS 8和Xcode 6。自从我第一次编写代码以来,代码没有任何变化,但奇怪的是,现在,当我在iOS 8设备上选择文本字段时,键盘会出现,而在iOS 7设备上则没有 为什么会这样?有什么想法吗 这是我的密码: #import "BBFeatVC.h" @inte
#import "BBFeatVC.h"
@interface BBFeatVC ()
@end
@implementation BBFeatVC
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.featTextField.delegate = self;
// Set label
self.featLabel.numberOfLines = 0;
// enhance keypad
UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Apply" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
nil];
[numberToolbar sizeToFit];
self.featTextField.inputAccessoryView = numberToolbar;
}
-(void)cancelNumberPad{
[self.featTextField resignFirstResponder];
}
-(void)doneWithNumberPad{
NSString *numberFromTheKeyboard = self.featTextField.text;
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *num = [f numberFromString:numberFromTheKeyboard];
NSInteger newStat = [num integerValue];
[[NSUserDefaults standardUserDefaults] setInteger:newStat forKey:self.featStat];
[self.featTextField resignFirstResponder];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
如果真的有一条红鲱鱼的话,那就是一条红鲱鱼。事实证明,这是一个iOS模拟器检测到硬件键盘的案例,因此没有提升模拟的iPhone键盘。我认为该代表正在使用iOS 8而不是iOS 7的原因是因为我的设备运行iOS 8,所以我在测试该版本的iOS时会在设备上进行测试,而在需要测试iOS 7时,我会使用模拟器。一旦我在模拟器上测试了iOS8,我发现我的假设有缺陷,我意识到区别不是iOS版本,而是设备和模拟器。我纠正了这个问题,进入模拟器,然后在硬件菜单,然后键盘,然后取消选中“连接硬件键盘”选项 这使我感到非常沮丧。我希望有人能从我的帖子中获益