我使用此代碼在我的UIAlertView中實現的UITextField:UIAlertView中使用的UITextField和長消息
UIAlertView *receivedAlert = [[UIAlertView alloc] initWithTitle:message message:[NSString stringWithFormat:@"%@\n\n", [itemNameRows objectAtIndex:currentItem]] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit", nil];
receivedField = [[UITextField alloc] initWithFrame:CGRectMake(16,70,252,25)];
receivedField.keyboardType = UIKeyboardTypeNumberPad;
receivedField.textAlignment = UITextAlignmentCenter;
receivedField.borderStyle = UITextBorderStyleRoundedRect;
receivedField.keyboardAppearance = UIKeyboardAppearanceAlert;
[receivedAlert addSubview:receivedField];
[receivedAlert show];
[receivedAlert release];
時,我有一個消息,是超過2線長,就會出現問題。警報視圖正確調整大小,但文本字段不會向下移動以容納較長的行。有任何想法嗎?
我可以在縮短消息字符串的情況下解決,如果必須的話。