如何在键盘顶部显示子视图?

时间:2011-07-06 17:29:44

标签: iphone objective-c ios cocoa-touch uiview

我正在添加一个淡入淡出的视图,为我的用户提供成功登录等提醒。不幸的是,视图没有出现在键盘上方,所以有一半被隐藏,因为我在中心显示它。

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]

没有运气。

2 个答案:

答案 0 :(得分:1)

听起来你真的应该使用UIAlertView。这将显示在键盘上。

以下是有关自定义提醒视图的一些资源:

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/

答案 1 :(得分:0)

您可以通过在键盘显示时修改其属性或者当您的用户转到下一个字段时为其设置动画。