這讓我非常煩惱,因爲我以前在應用程序的早期版本中使用過MBProgressHUD。UITabBarController中的MBProgressHUD
無論我怎樣嘗試設置代碼在我的項目,以顯示MBProgressHUD,我總是收到「蘋果的Mach-O連接器錯誤」:「爲i386硬件架構未定義的符號: ‘_OBJC_CLASS _ $ _ MBProgressHUD’,從引用: objc級-REF IN Home.o LD:符號(多個)未找到i386硬件架構 鐺:錯誤:連接器命令,退出代碼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上最高的看法繼承人微弱但總是收到相同的錯誤,誰能看到我的編碼中可能是一個簡單的錯誤?