您的位置:首页 > Web前端

IOS_Sheet_TextFeild_学习记录

2014-05-22 22:48 288 查看
#import "LoginViewController.h"

@interface LoginViewController ()<UITextFieldDelegate,UIActionSheetDelegate>

@property (weak, nonatomic) IBOutlet UITextField *name;

@property (weak, nonatomic) IBOutlet UITextField *password;

@end

@implementation LoginViewController

- (void)viewDidLoad

{

    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (IBAction)login:(id)sender {

    

    NSString *name = self.name.text;

    NSString *password = self.password.text;

    if ([name isEqualToString:@"admin"] && [password isEqualToString:@"admin"]) {

        UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:@"登录成功"

                                                                 delegate:self

                                                        cancelButtonTitle:@"取消"

                                                   destructiveButtonTitle:@"确定"

                                                        otherButtonTitles:@"其他", nil];

        [actionsheet showInView:self.view];

    }

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];

    return true;

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"登陆"

                                                    message:@"输入用户名密码"

                                                   delegate:self

                                          cancelButtonTitle:@"取消"

                                          otherButtonTitles:@"确定",nil];

    alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;

    [alert show];

    

}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uitextfield