如何显示在界面生成器中创建的自定义 uialertview
我在 ib 中创建了一个自定义 uialertview,带有两个按钮和一个文本字段。 然后我以这种方式创建一个 .h 和一个 .m:
#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
和 .m :
#import "DialogWelcome.h"
@implementation DialogWelcome
@synthesize text;
-(IBAction)ok:(id)sender{
}
-(IBAction)annulla:(id)sender{
}
@end
我还没有实现方法,因为首先我需要展示它! 我在视图控制器中以这种方式调用它:
- (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?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 UIAlertView 类参考:
因此,您尝试做的事情是明确不允许的。
From the UIAlertView Class Reference:
So, what you're trying to do is explicitly not allowed.