gpt4 book ai didi

iphone - 如何显示在界面生成器中创建的自定义 uialertview

转载 作者:行者123 更新时间:2023-12-03 20:53:28 28 4
gpt4 key购买 nike

我在 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

我还没有实现方法,因为首先我需要展示它!我在 View Controller 中这样调用它:

- (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?

最佳答案

来自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.

因此,您尝试执行的操作是明确不允许的。

关于iphone - 如何显示在界面生成器中创建的自定义 uialertview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7871800/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com