如何用笔尖制作伪警报视图?

发布于 2024-09-15 02:30:39 字数 76 浏览 3 评论 0原文

我想在屏幕上放置一个伪 UIAlertView,它只是一个 UIView 加上我用 IB 创建的笔尖中的按钮......最好的方法是什么?

I want to put on the screen a pseudo-UIAlertView which is just a UIView plus buttons in a nib I've created with IB.... what's the best way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风蛊 2024-09-22 02:30:39

在 Xcode 中创建一个 UIViewController 并让它创建 Xib。在 IB 中添加/编辑控件。然后加载你的视图控制器。将其保留在您创建它的类中,然后将其视图添加为调用类的子视图。像这样:

PseudoAlertViewController *controller = [[PseudoAlterViewController alloc] init];
[self setAlertViewController:controller]; // nonatomic, retained ivar
[[self view] addSubview:[controller view]]; //assume calling from view controller
[controller release], controller = nil;

当您将视图添加到子视图时,除非您设置框架,否则它只会将其添加到视图原点,因此在将其添加到视图层次结构之前也要这样做:

// You'll have to calculate centeredFrame
[[controller view] setFrame:centeredFrame];

Create a UIViewController in Xcode and have it create the Xib. Add/Edit the controls in IB. Then load your view controller. Retain it in the class where you're creating it and then add its view as a subview of your calling class. Something like:

PseudoAlertViewController *controller = [[PseudoAlterViewController alloc] init];
[self setAlertViewController:controller]; // nonatomic, retained ivar
[[self view] addSubview:[controller view]]; //assume calling from view controller
[controller release], controller = nil;

When you add the view to your subview it will just add it at the view origin unless you set the frame, so do that as well before adding it to the view hirarchy:

// You'll have to calculate centeredFrame
[[controller view] setFrame:centeredFrame];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文