gpt4 book ai didi

ios - textFieldShouldReturn 不再有效

转载 作者:行者123 更新时间:2023-11-28 18:07:55 26 4
gpt4 key购买 nike

在 iPad 上,textFieldShouldReturn 不再工作。直到大约五分钟前我一直在工作,突然间不再调用该方法……有什么想法吗?下面是代码,唯一改变的是 UITextView 的通知……谢谢!

- (BOOL)textFieldShouldReturn:(UITextField *)tf
{
NSString* newName = textField.text;
textLabel.text = textField.text;
NSLog(@"Called!");

newName = [newName stringByAppendingPathExtension:@"txt"];
NSString* newPath = [[currentFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newName];
NSLog(@"%@",newPath);
[[NSFileManager defaultManager] moveItemAtPath:currentFilePath toPath:newPath error:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"DataSaved" object:nil];
[currentFilePath retain];
currentFilePath = newPath;
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
[currentFilePath retain];
// Write out the contents of home directory to console

NSLog(@"Documents directory: %@", [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil]);

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
textLabel.alpha = 1.0;
textField.alpha = 0.0;
[UIView commitAnimations];
[tf resignFirstResponder];
return YES;

最佳答案

最好的可能性 - 您可能不小心删除了文本字段的委托(delegate)。

关于ios - textFieldShouldReturn 不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7519507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com