Reputation: 13061
I've created a custom uialertview in ib, with two button and a textfield. Then i create a .h and a .m in this way:
#import <UIKit/UIKit.h>
@interface DialogWelcome : UIAlertView{
IBOutlet UITextField *text;
UIButton *ok;
UIButton *annulla;
}
@property(nonatomic,retain) UITextField *text;
- (IBAction)ok:(id)sender;
- (IBAction)annulla:(id)sender;
@end
and .m :
#import "DialogWelcome.h"
@implementation DialogWelcome
@synthesize text;
-(IBAction)ok:(id)sender{
}
-(IBAction)annulla:(id)sender{
}
@end
i've not implement methods cause in first i need to show it! i call this in viewcontroller in this way:
- (void)viewDidLoad
{
[super viewDidLoad];
DialogWelcome *alert = [[DialogWelcome alloc] initWithTitle:@"Welcome"
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
[alert show];
dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC*2.0);
dispatch_after(delay, dispatch_get_main_queue(), ^{
[alert dismissWithClickedButtonIndex:0 animated:YES];
});
[alert release];
}
This will show a normal uialertview empty with a title. why it doesn't show my custom uialertview?
Upvotes: 2
Views: 2138
Reputation: 386008
From the UIAlertView Class Reference:
The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
So, what you're trying to do is explicitly not allowed.
Upvotes: 3