iphone - 如何使 subview 显示在键盘顶部?

标签 iphone objective-c ios cocoa-touch uiview

我正在添加一个淡入的 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/

相关文章:

iphone - 在 iPhone 上使用 AVAudioPlayer 时崩溃

html - iPhone 上的 Safari 是否有等同于 Android 的 <meta name ='viewport' content ='target-densitydpi=device-dpi' > 的东西?

ios - 第一个 iOS 应用程序 - 我应该使用 RubyMotion 还是 Objective-C?

c# - 仅在特定 html 文件上从 uiwebview 中删除表单助手 (Phonegap)

iphone - 以编程方式更改应用程序图标

iphone - 需要从 uiwebview 打开 safari 中的链接?

objective-c - 如何停止警告 UIView 可能无法响应选择器

objective-c - 使用多个窗口

ios - NSArray 改变 NSNumber 的类型

ios - 呈现 View 时,VoiceOver 不会始终关注 UILabel