以前のバージョンのアプリでMBProgressHUDを使用していたので、これは良い1週間私を悩ませてきました。
プロジェクトでMBProgressHUDを表示するようにコードを設定しようとしても、常に「Apple Mach-O Linker Error」:「アーキテクチャi386の未定義のシンボル:「_ OBJC_CLASS _ $ _ MBProgressHUD」、参照元:objc-class-ref in Home.o ld:アーキテクチャi386のシンボルが見つかりませんclang:エラー:リンカーコマンドが終了コード1で失敗しました(-vを使用して呼び出しを確認してください) "
以下は、アプリケーションのmファイルで使用しているソースコードです。
#import "AppDelegate.h"
#import "Home.h"
#import "SSFB.h"
#import "SST.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *home = [[Home alloc] initWithNibName:@"Home" bundle:nil];
UIViewController *ssfb = [[SSFB alloc] initWithNibName:@"SSFB" bundle:nil];
UIViewController *sst = [[SST alloc] initWithNibName:@"SST" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[home, ssfb, sst];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
@end
Home.h
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
@interface Home : UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *homeWebView;
IBOutlet UINavigationBar *homeNavBar;
UIAlertView *loadingAlert;
UIActivityIndicatorView *loadingTicker;
MBProgressHUD *HUD;
}
@property (retain, nonatomic) IBOutlet UINavigationBar *homeNavBar;
@property (retain, nonatomic) UIAlertView *loadingAlert;
@property (retain, nonatomic) UIAlertView *loadingTicker;
-(IBAction)refreshhomeWebView:(id)sender;
-(void)myTask;
-(void)showWithLabel;
@end
そして最後にHome.mファイル:
@implementation Home
@synthesize homeNavBar = _homeNavBar, loadingAlert, loadingTicker = _loadingTicker;
-(void)myTask{
while(homeWebView.loading){
}
}
- (void)showWithLabel {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}
-(void)webView:(UIWebView *)homeWebView didFailLoadWithError:(NSError *)error{
NSLog(@"error");
if ([error code] == -1009 || [[error localizedDescription] isEqualToString:@"no Internet connection"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"There is currently no internet access." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
if ([error code] == -1001 || [[error localizedDescription] isEqualToString:@"timed out"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The connection, please try again." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
if ([error code] == -1004 || [[error localizedDescription] isEqualToString:@"can't connect to host"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can not connect to the webpage's host at this time, please try again later." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
else{
}
}
-(void)webViewDidStartLoad:(UIWebView *)homeWebView{
[self showWithLabel];
NSLog(@"start load");
}
-(void)webViewDidFinishLoad:(UIWebView *)homeWebView{
}
-(IBAction)refreshhomeWebView:(id)sender{
[homeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.socialstarsclub.com"] ]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Home", @"Home");
self.tabBarItem.image = [UIImage imageNamed:@"home_30"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.homeNavBar setBarStyle:UIBarStyleBlackOpaque];
[homeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.socialstarsclub.com"] ]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
'showWithLable'のコードのバリエーションを試して、HUDを最高のビューの相続人に設定しようとしましたが、常に同じエラーが発生します。コーディングの単純な間違いを誰かが確認できますか?