UIAlertView 警示框
//創(chuàng)建一個(gè)警示框?qū)ο?//參數(shù):1.提示標(biāo)題 2.提示的信息內(nèi)容 3.設(shè)置代理(設(shè)置方法的調(diào)用者) 4.取消按鈕的標(biāo)題 5.其他按鈕標(biāo)題
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"信息" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確認(rèn)", nil];
//警示框風(fēng)格
alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
//讓alertView展示一下
[alertView show];
//alertView有兩個(gè)輸入框的情況下
//textFieldAtIndex 根據(jù)索引從警示框上找輸入框,根據(jù)索引
UITextField *nameTF = [alertVIew textFieldAtIndex:0];
UITextField *phoneTF = [alertVIew textFieldAtIndex:1];
//UIAlertView這個(gè)類中的一些協(xié)議方法
//參數(shù):1.類似于按鈕點(diǎn)擊事件中的形參button, 在多個(gè)alertView對(duì)象的情況下, 用于區(qū)分不同的alertView, 你點(diǎn)擊哪一個(gè)alertView, 會(huì)通過該形參把對(duì)應(yīng)的alertView對(duì)象傳遞過來; 2.buttonIndex:用于區(qū)分alertView上的按鈕的;
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"取消");
}
else if (buttonIndex == 1)
{
NSLog(@"確認(rèn)");
}
}
UIActionSheet 底部彈窗
//底部彈窗
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"退出登錄" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"確定" otherButtonTitles:@"考慮考慮", nil];
//展示行為列表
[sheet showInView:self.view];
//UIActionSheet的協(xié)議方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;