UIButton,UIAlertView

来源:互联网 发布:charge是什么软件 编辑:程序博客网 时间:2024/06/05 01:04

#import "AppDelegate.h"


@interface AppDelegate () <UIAlertViewDelegate>


@end


@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColorwhiteColor];

    [self.windowmakeKeyAndVisible];

    [_windowrelease];

    

    UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem];

    button.frame =CGRectMake(50,50, 50,30);

    button.backgroundColor = [UIColorgrayColor];

    [button setTitle:@"点击"forState:UIControlStateNormal];

    [button addTarget:selfaction:@selector(buttonWithType:)forControlEvents:UIControlEventTouchUpInside];

    [self.windowaddSubview:button];

    

    

    returnYES;

}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    // 当点击了alertView上的按钮之后,会调用这个方法

    NSLog(@"%ld", buttonIndex);

}


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

{

    NSLog(@"%ld", buttonIndex);

}


- (void)buttonWithType:(UIButton *)button

{

    NSLog(@"GOOD");

    UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"title"message:@"message"delegate:selfcancelButtonTitle:@"残忍拒绝"otherButtonTitles:@"赏个脸",@"啵一个",nil];

    [alertView show];

    [alertView release];

}

- (void)dealloc

{

    [_windowrelease];

    [superdealloc];

}

0 0
原创粉丝点击