How to make a pseudo-alertview with a nib?
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];
精彩评论