2011-10-24 8 views
2

ibで2つのボタンとテキストフィールドを使用してカスタム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を表示していないのですか? UIAlertView Class Referenceから

答えて

3

UIAlertViewクラスは、そのままではなく サポートサブクラス化を行い使用することを意図しています。このクラスのビュー階層はプライベートで、 は変更しないでください。

あなたがしようとしていることは、明示的に許可されていません。

+0

:(何ができますか? – JackTurky

+0

モーダルビューを使用してみてください。http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html –

関連する問題