gpt4 book ai didi

uiwebview - UITabBarController 中的 MBProgressHUD

转载 作者:行者123 更新时间:2023-12-04 05:25:52 27 4
gpt4 key购买 nike

这让我困扰了好一周,因为我以前在应用程序的早期版本中使用过 MBProgressHUD。

无论我如何尝试在我的项目中设置代码以显示 MBProgressHUD,我总是收到“Apple Mach-O 链接器错误”:“架构 i386 的 undefined symbol :
“_OBJC_CLASS_$_MBProgressHUD”,引用自:
Home.o 中的 objc-class-ref
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

主页.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”的代码变体,试图在最高 View 继承人上设置 HUD,但总是收到相同的错误,谁能看到我的编码中可能存在的简单错误?

最佳答案

哇。出于某种原因,使用 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];

关于uiwebview - UITabBarController 中的 MBProgressHUD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13217798/

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