我正在添加一个淡入的 View ,它会向我的用户发出警报,例如成功登录等。不幸的是,该 View 没有出现在键盘上方,所以它的一半被隐藏了,因为我在中心显示它。
case 401:
alertBezel = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:alertBezel];
// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
alertBezel.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
alertBezel.mode = MBProgressHUDModeCustomView;
alertBezel.labelText = @"Unauthorized User!";
[alertBezel show:YES];
[alertBezel hide:YES afterDelay:1];
break;
我也试过获取关键窗口:
[[UIApplication sharedApplication] keyWindow]
运气不好。
最佳答案
听起来您真的应该使用 UIAlertView。这将显示在键盘上。
以下是有关自定义警报 View 的一些资源:
how i can implement a custom UIAlertview with a progress bar and a cancel button?
http://www.skylarcantu.com/blog/2009/08/14/custom-uialertview-color-chooser/
关于iphone - 如何使 subview 显示在键盘顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6600532/