gpt4 book ai didi

xcode - 通用应用程序 - iPad View 加载,但我无法将任何 ImageView 链接到 UIImage 对象而不会出现错误

转载 作者:行者123 更新时间:2023-11-28 17:46:31 25 4
gpt4 key购买 nike

我正在开发一个简单的通用应用程序,屏幕上基本上有 10 个图像和 10 个按钮。如果点击button2,image2会消失,再次点击button2,image2会重新出现。我的 iphone 版本运行完美,但我在 iPad 上遇到问题。

我有应用程序加载 MainWindow-iPad.xib,它从 AppNameViewController-iPad.xib 获取 View 。我还有 AppNameViewController-iPad.h/.m,它具有所需的方法和 UIImage 对象。

现在,如果我没有任何链接,我可以完美地看到 iPad View 。如果我将按钮与其相应的方法链接起来, View 仍会加载。如果我将 ImageView 与相应的 UIImage 链接(IE 将 image2.png 与 UIImage *image2 链接起来)并尝试运行该程序,我会在调试字段中收到此错误:

2011-04-12 12:46:45.400 AppName[14106:207] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image2.'

然后 Xcode 将我带到 main.m 并在这一行给出错误:

int main(int argc, char *argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //THIS LINE HERE
[pool release];
return retVal;
}

错误显示“线程 1:程序接收到信号“SIGABRT”。

我不确定这是否重要,但我有一个 AppDelegate.h/m 用于整个应用程序,但有一个单独的 ViewController.h/m 用于 iPhone 和 iPad。我有一种感觉,我只是没有将某些东西与我的 xibs 正确链接,但我是一个非常新的开发人员,我只是无法弄清楚。如果有人能帮我解决这个问题,非常感谢。

最佳答案

不知道它是否对您有帮助,但我在第一次尝试构建通用应用程序时收到了完全相同的错误消息。我没有做任何链接,所以根本原因可能不同。

我正在运行 Xcode 4,在你的目标下你可以选择你的主界面。如果我选择 AppNameViewController 我会遇到你的问题。如果我选择 MainWindow,它工作正常。

我远不是这方面的专家,但它可能会引导您找到正确的答案...

为什么 Apple 不能提供一些更通用的应用教程?

祝你好运!

关于xcode - 通用应用程序 - iPad View 加载,但我无法将任何 ImageView 链接到 UIImage 对象而不会出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5641101/

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