這玩意有時不用就忘,還是記錄一下吧
添加:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"新建文件夾" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
UITextField *txtName = [alert textFieldAtIndex:0];
txtName.placeholder = @"請輸入名稱";
[alert show];
代理點擊處理:
#pragma mark - 點擊代理
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
UITextField *txt = [alertView textFieldAtIndex:0];
//獲取txt內容即可
}
}
UIAlertView在iOS8之后被廢棄了,系統建議用UIAlertController實現,實現更簡單了
不過在一些純View上顯示提示框,還是用UIAlertView或自定義提示框更方便點。
