1

似乎无法在这里解决这个问题。知道需要改变什么吗?我正在使用 Xcode 4.2。

错误: AppDelegate.m:23:6:错误:接收器类型“AppDelegate”例如消息未声明带有选择器“setupHUD”的方法 [4]

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];

    LoginViewController *loginVC = [[LoginViewController alloc] init];
    UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:loginVC];
    navCon.navigationBarHidden = YES;
    self.window.rootViewController = navCon;
    [self setupHUD];

    [self.window makeKeyAndVisible];
    return YES;
}


- (void) setupHUD
{
    //setup progress hud
    self.HUD = [[MBProgressHUD alloc] initWithFrame:self.window.bounds];
    [self.window addSubview:self.HUD];
    self.HUD.dimBackground = YES;
    self.HUD.minSize = CGSizeMake(150.f, 150.f);
    self.HUD.delegate = self;
    self.HUD.isCancelButtonAdded = YES;
    self.HUD.labelText = @"Loading";
}
4

1 回答 1

1

在 Xcode 4.3 之前,您需要转发在同@implementation一块中调用的声明方法,因此请确保将声明添加setupHUD到类扩展(AppDelegate.m 中以 开头的声明列表@interface AppDelegate ())或@interfaceAppDelegate 中的块。 H。

例如,在 AppDelegate.m 中:

@interface AppDelegate ()
// Other declarations...
- (void)setupHUD;
@end

或者在 AppDelegate.h 中:

@interface AppDelegate : NSObject <UIApplicationDelegate>
// Other declarations
- (void)setupHUD;
@end
于 2013-11-07T05:34:50.627 回答