iOS Objective-C wrap text of UITextField in UIAlertView and dynamically adjust height based on content -
i have uialertview alertviewstyle of uialertviewstyleplaintextinput. i'm trying find way make uitextfield of uialertview adjust height , wrap text based on content user types.
to quite honest, haven't slightest clue how this.
here of code:
-(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]; }
it not possible have uitextfield multiple lines , dynamic height.
to achieve please create custom alert , add uitextview uitextviewcan have multiple lines. override textviewdidchange: , calculate size of text in textview sizewithfont:constrainedtosize:linebreakmode:. return cgsize based on height adjust height of uitextview , alert.
thanks
Comments
Post a Comment