iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 将IBOutlet连接到UITextField后出错大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_489_3@概述 当我将IBOutlet连接到UITextField时,我遇到了这个奇怪的错误.这真的很奇怪,因为它只发生在这个视图控制器中.我有两个与这个几乎相同的其他视图控制器,它们功能完美.我的故事板中有一个表视图控制器.它有2个分组的部分,每个部分都有静态单元格.每个单元格中都有一个UITextField.现在,如果我只是运行它而没有将textfields连接到我的类,视图加载正常.但是,当我连接它们时,一
当我将IBOutlet连接到UITextField时,我遇到了这个奇怪的错误.这真的很奇怪,因为它只发生在这个视图控制器中.我有两个与这个几乎相同的其他视图控制器,它们功能完美.我的故事板中有一个表视图控制器.它有2个分组的部分,每个部分都有静态单元格.每个单元格中都有一个UITextField.现在,如果我只是运行它而没有将textfields连接到我的类,视图加载正常.但是,当我连接它们时,一旦视图加载 – 应用程序崩溃并出现此错误,每个文本字段一个:[UITextField StringByTrimmingCharactersInSet:]:发送到实例的无法识别的选择器

知道这可能是什么原因吗?我很困惑,因为我有其他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

解决方法@H_618_31@
您在视图控制器中声明了两个属性,标题和描述,它们分别由UIViewControlller和NSObject定义.最初定义的这两个属性都是NSStrings.

iOS可能正在尝试访问这些属性,期望获得NSString,并获得一个UITextField.

尝试重命名这些属性,你的问题应该消失.

大佬总结

以上是大佬教程为你收集整理的iphone – 将IBOutlet连接到UITextField后出错全部内容,希望文章能够帮你解决iphone – 将IBOutlet连接到UITextField后出错所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。