如何在tweak应用程序中将UIView添加到整个iOS的最前端视图?

时间:2015-01-12 03:24:37

标签: ios objective-c jailbreak mbprogresshud tweak

我的应用是在SpringBoard中运行的调整应用,我想在其中使用MBProgressHUD,但是需要指定要添加的视图,因此如何获取字体的大多数视图整个iOS

我应该这样做:

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:fronMostView animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = [Localization localize:@"Finished!"];
[hud hide:YES afterDelay:1];

2 个答案:

答案 0 :(得分:0)

添加此视图的最佳位置是AppDelegate。将视图添加到appDelegate窗口将显示在整个应用程序的最前面。此外,它会保持在最顶层,直到您从appDelegate窗口隐藏或删除此视图。

MBProgressHUD类中创建AppDelegate的全局对象,并创建show / hide方法。

分别调用此方法以方便您使用。

例如:

@property (nonatomic, strong)  MBProgressHUD   *hud;

- (void) showProgress:(NSString *)message {

    // Create a loading view
    if (!self.hud) {
        _hud = [MBProgressHUD showHUDAddedTo:fronMostView animated:YES];
        self.hud.mode = MBProgressHUDModeText;

        // Add Progress to window.
       [self.window addSubview:self.hud];
    }

    self.hud.hidden = NO;
    self.hud.labelText = [Localization localize:message];
}


- (void) hideLoadingMessage {
    self.hud.labelText = [Localization localize:@"Finished!"];
    [self.hud hide:YES afterDelay:1];
}

答案 1 :(得分:0)

尝试

UIWindow* window = [[UIApplication sharedApplication] keyWindow];

UIWindow *window = [UIApplication sharedApplication].windows.lastObject;

然后

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];

Here is a topic about this,也许它会有用。