Iphone 如何显示在interface builder中创建的自定义uialertview
我在ib中创建了一个自定义uialertview,它有两个按钮和一个文本字段。 然后我用这种方式创建a.h和a.m:Iphone 如何显示在interface builder中创建的自定义uialertview,iphone,objective-c,customization,uialertview,Iphone,Objective C,Customization,Uialertview,我在ib中创建了一个自定义uialertview,它有两个按钮和一个文本字段。 然后我用这种方式创建a.h和a.m: #import <UIKit/UIKit.h> @interface DialogWelcome : UIAlertView{ IBOutlet UITextField *text; UIButton *ok; UIButton *annulla; } @property(nonatomic,retain) UITextField *text
#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
我没有实现方法,因为首先我需要展示它!
我用以下方式在viewcontroller中称其为:
- (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];
}
这将显示一个带有标题的空视图。为什么不显示我的自定义uialertview?来自:
UIAlertView类旨在按原样使用,而不是按原样使用
支持子类化。此类的视图层次结构是私有的,并且
不能修改
因此,您尝试执行的操作是明确不允许的。尝试使用模式视图。
- (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];
}