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中完美运行,但在ios 6中运行不正常。我应该在ios 6.1上进行哪些更改
答案 0 :(得分:0)
你不能轻易改变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];