![](/img/trans.png)
[英]How to get the instance(UIApplication) of the front most application from SpringBoard tweak in iOS?
[英]How to add an UIView to the front most view of the whole iOS in the tweak application?
我的应用程序是一个运行在SpringBoard
的调整应用程序,我想在其中使用MBProgressHUD
,但是它需要指定要添加的视图,那么如何才能获得整个iOS
大多数视图的字体?
我应该这样做:
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:fronMostView animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = [Localization localize:@"Finished!"];
[hud hide:YES afterDelay:1];
添加此视图的最佳位置是AppDelegate
。 将视图添加到appDelegate窗口将显示在整个应用程序的最前面。 除非您在appDelegate窗口中隐藏或删除此视图,否则它仍将保留在顶部。
在AppDelegate
类中创建MBProgressHUD
的全局对象,并创建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];
}
尝试
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
要么
UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
然后
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
这是有关此的主题 ,也许会有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.