开发者

How to make a pseudo-alertview with a nib?

开发者 https://www.devze.com 2023-01-12 11:34 出处:网络
I want to put on the screen a pseudo-UIAlertView which i开发者_JAVA技巧s just a UIView plus buttons in a nib I\'ve created with IB.... what\'s the best way of doing this?Create a UIViewController in X

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


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消