gpt4 book ai didi

ios - 对如何修复这些错误 (iOS) 感到困惑……有什么建议吗?

转载 作者:可可西里 更新时间:2023-11-01 03:32:32 25 4
gpt4 key购买 nike

我完全不熟悉 iOS 开发,并且通过书籍来学习。按照早期章节之一的说明,我编写了一个简短的应用程序(代码如下)。它只需要一些文本输入并更改标签的文本以匹配它。但是,在模拟器中运行代码后,单击文本字段时出现以下错误:

2012-06-08 11:26:06.595 HelloNoun[14926:f803] Opening '/Users/clhu/Library/Application Support/iPhone Simulator/5.1/Library/Caches/com.apple.keyboards/images/1859589221' failed: 'No such file or directory' (2)

2012-06-08 11:26:06.702 HelloNoun[14926:f803] 'INSERT INTO store VALUES (?,?,?,?,?,?,?,?)' constraint failed (19)

然后,当我按下按钮设置标签时,我也会遇到这些错误:

2012-06-08 11:27:09.050 HelloNoun[14926:f803] -[UIView text]: unrecognized selector sent to instance 0xb75ac80

2012-06-08 11:27:09.051 HelloNoun[14926:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView text]: unrecognized selector sent to instance 0xb75ac80'

* First throw call stack:

(0x13c7022 0x1558cd6 0x13c8cbd 0x132ded0 0x132dcb2 0x21a7 0x13c8e99 0x1414e 0x140e6 0xbaade 0xbafa7 0xba266 0x393c0 0x395e6 0x1fdc4 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da 0x12fdd84 0x12fdc9b 0x12b07d8 0x12b088a 0x11626 0x1dad 0x1d15) terminate called throwing an exception(lldb)

我已经查看了我的连接并多次回溯我的步骤,没有发现任何明显的错误(尽管我对此绝对是新手)。谁能帮我指出正确的方向?谢谢!


代码如下:

// ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *userOutput;
@property (strong, nonatomic) IBOutlet UITextField *userInput;

- (IBAction)setOutput:(id)sender;

@end

// ViewController.m

#import "ViewController.h"

@implementation ViewController
@synthesize userOutput;
@synthesize userInput;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
[self setUserOutput:nil];
[self setUserInput:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)setOutput:(id)sender
{
self.userOutput.text = self.userInput.text;
}
@end

最佳答案

我以前从未见过第一个错误,但您可以尝试删除路径 /Users/clhu/Library/Application Support/iPhone Simulator/5.1/Library/Caches 中的缓存文件夹.模拟器应该足够聪明,可以重新创建它。

对于第二个错误,我通常会在将属性连接到 NIB 中的错误 View 时看到。它看起来像属性 userOutput指向 UIView 而不是 UITextField。您可以检查 NIB 中的连接或通过将以下行添加到 userOutput 来打印出 userOutput 的值 setOutput: .

NSLog(@"%@", self.userOutput);

您日志中的输出应该类似于

<UITextField: 0x6fea9f0; frame = (0 0; 100 31); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x6fec700>>

关于ios - 对如何修复这些错误 (iOS) 感到困惑……有什么建议吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10951770/

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