0
高度I與的UIAlertViewStylePlainTextInput
的alertViewStyle
一個UIAlertView
。我試圖找到一種方法來使UIAlertView
的UITextField
調整其高度,並根據用戶輸入的內容來包裝其文本。iOS的目標C渦卷文本並動態地調整基於內容
說實話,我沒有絲毫的線索如何做到這一點。
下面是我的一些代碼:
-(void)updateTicket:(id)sender
{
UIButton *sndr = (UIButton*)sender;
int index = sndr.tag;
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTag:-7];
[alert setDelegate:self];
[alert setTitle:[NSString stringWithFormat:@"Update Ticket #%i", [ticketIDs[index] intValue]]];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert textFieldAtIndex:0].placeholder = @"Note";
[alert textFieldAtIndex:0].tag = index;
[alert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;
[alert textFieldAtIndex:0].autocorrectionType = UITextAutocorrectionTypeYes;
[alert textFieldAtIndex:0].autoresizingMask = UIViewAutoresizingFlexibleHeight;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"OK"];
[alert setCancelButtonIndex:0];
[alert show];
}
它不可能爲UITextField,因爲文本字段只需要1行文本。所以你必須用UITextView創建自定義警報 – 2014-09-19 20:10:37