它
if ([district.text isEqualToString:@""])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else if([myTextField.text isEqualToString:@""])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else if ([catname.text isEqualToString:@""])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else if([msg.text isEqualToString:@""])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
这是我的代码,它在ios7中完美运行,但在ios6中则不然。 我应该进行哪些更改才能在iOS 6.1上运行
您无法在 iOS 7 中轻松更改 UIAlertView 的视图层次结构。(你也不应该;文档特别告诉你不要这样做。前往开发人员论坛查看有关它的长时间讨论。
在您的情况下,一种替代方法是设置 alert.alertViewStyle = UIAlertViewStylePlainTextInput;这将为您添加一个文本字段。您可以使用 UITextField *textField = [alertView textFieldAtIndex:0]; 在 UIAlertView 委托回调中访问它。
例:
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Alert"
message:@"enter your details:"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
/* Display a numerical keypad for this text field */
UITextField *textField = [alertView textFieldAtIndex:0];
textField.keyboardType = UIKeyboardTypeNumberPad;
[alertView show];