2012-11-04 3 views
2

이전에 앱의 이전 버전에서 MBProgressHUD를 사용 했으므로 좋은 주간 저를 괴롭게했습니다.UITabBarController의 MBProgressHUD

아무리 MBProgressHUD을 보여 내 프로젝트에 코드를 설정하려고하는 방법, 난 항상 '애플 마하-O 링커 오류'가 나타날 : "아키텍처 I386에 대한 정의되지 않은 심볼 : "_OBJC_CLASS _ $ _ MBProgressHUD "에서 참조를 : 오류 : 아키텍처 i386을 그 소리 찾을 수 없습니다 기호 (들) : Home.o LD에서 objc 수준의-REF 링커 명령은 다음

소스입니다 "(호출을보기 위해 사용 -v) 종료 코드 1로 실패 코드 내 응용 프로그램 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 

항상 고통으로하지만, 가장 높은보기 상속인에 HUD를 설정하려고 'showWithLable' 동일한 오류가 발생하면 누구나 코딩에서 간단한 실수가 될 수 있습니다.

답변

3

와우. Clean and Build (Command + Shift + K)를 사용하고이 스레드 (Got error in implementing EGOPhotoViewer)를 수행 한 다음에는 대상 메뉴의 컴파일 된 소스 아래에 MBProgressHUD.h & MBProgressHUD.m을 모두 추가해야했습니다.

다음 변경 :

HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; 

&

[self.navigationController.view addSubview:HUD]; 

사람 :

HUD = [[MBProgressHUD alloc] initWithView:self.tabBarController.view]; 

&

[self.tabBarController.view addSubview:HUD]; 
,