0

AppDelegate.h:

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

+ (MBProgressHUD *)showGlobalProgressHUDWithTitle:(NSString *)title;

AppDelegate.m:

+ (MBProgressHUD *)showGlobalProgressHUDWithTitle:(NSString *)title {
UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
[MBProgressHUD hideAllHUDsForView:window animated:YES];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
hud.labelText = title;
return hud;
}

在 AppDelegate.m 的 someOtherMethod 中:

[self showGlobalProgressHUDWithTitle:@"Checking for Updates"];  //No visible interface for AppDelegate declares the selector 'showGlobalProgressHUDWithTitle:'

为什么?界面中的其他方法都是可见的,但为什么不是这个呢?它与作为类方法有关吗?

4

1 回答 1

2

您正在从对象实例(self)调用类方法。

在您的方法声明和实现中将 + 更改为 - ,然后您就完成了排序。

于 2012-09-12T06:04:49.807 回答