2
我在ib中創建了一個自定義uialertview,帶有兩個按鈕和一個文本框。 然後,我用這種方式創建的.h和.M:如何顯示在界面生成器中創建的自定義uialertview
#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
我還沒有實現方法引起首先我需要表現出來! 我這樣稱這種現象的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?
:(我該怎麼辦? – JackTurky
嘗試使用模態視圖。http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html –