当我将 IBOutlet 连接到 UITextField 时,我遇到了这个奇怪的错误。这真的很奇怪,因为它只发生在这个视图控制器中。我还有另外两个与这个几乎相同的视图控制器,它们运行良好。我的故事板中有一个表格视图控制器。它有 2 个分组部分,每个部分都有静态单元格。每个单元格中都有一个 UITextField。现在,如果我只运行它而不将文本字段连接到我的类,则视图加载正常。但是,当我连接它们时,一旦视图加载-应用程序因此错误而崩溃,每个文本字段都有一个: [UITextField stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance
知道这可能是什么原因吗?我很困惑,因为我有其他具有相同内容的 tableview 控制器,但我从未收到此错误。
以下是一些屏幕截图,可帮助进一步解释我的情况:
这是我的 .m 文件的代码:
//
// IdeaViewController.m
// FinalJSApp
//
// Created by Jacob Klapper on 10/20/13.
//
//
#import "IdeaViewController.h"
@interface IdeaViewController ()
@end
@implementation IdeaViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
/*
#pragma mark - Navigation
// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end