我正在尝试实现SVProgressHUD Activity 指示器。我将这些类复制到我的项目中,并将以下代码添加到我的appDelegate中,但无法弄清楚它为什么崩溃。
我得到他们以下错误,并且不确定在哪里可以解决它:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SVProgressHUD", referenced from:
objc-class-ref in QuotesAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是代码:
#import "SVProgressHUD.h"
@implementation QuotesAppDelegate
- (void)startLoading
{
//call this in your app delegate instead of setting window.rootViewController to your main view controller
//you can show a UIActivityIndiocatorView here or something if you like
[SVProgressHUD show];
[self performSelectorInBackground:@selector(loadInBackground) withObject:nil];
}
- (void)loadInBackground
{
//do your loading here
//this is in the background, so don't try to access any UI elements
[self populateFromDatabase];
[SVProgressHUD dismiss];
[self performSelectorOnMainThread:@selector(finishedLoading) withObject:nil waitUntilDone:NO];
}
- (void)finishedLoading
{
//back on the main thread now, it's safe to show your view controller
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self copyDatabaseIfNeeded];
[self startLoading];
}
最佳答案
编辑
我提供的答案(请参阅我的原始答案)仅解决了此问题,但这不是正确的解决方案。有关正确的解决方案,请参见 Jim 答案
或 Parth Bhatt 链接。
为了完整起见
稍作试验,我发现当您在项目中拖放文件或目录时,Xcode(4.3.1)要求您选择正确的选项以将这些文件或目录添加到项目中。确保已选中“添加到目标”选项。
如果您错过了该选项,则需要执行以下步骤:
我的原始答案
如果将这些类拖到项目中,则可能是问题所在。
为避免该编译错误,请改用“将文件添加到YourProjectName”。
假设您的桌面上有一个目录,其中包含名为“SVProgressHUD”的.h和.m文件。
现在您必须:
希望能帮助到你。