新行textfield-iPhone
是否可以在新行textfield-iPhone,iphone,objective-c,uitextfield,Iphone,Objective C,Uitextfield,是否可以在textfield占位符中添加新行?比如: comment1= [[[UITextField alloc]initWithFrame:frame2]autorelease]; comment1.placeholder = @"Write maximum 200 \r characters here"; UITextField仅用于显示单行。如果要显示多行文本,必须使用UITextView。或者,您可以使用UILabel并设置“行数”属性。在iPhone中“\n”是新行字符。但是,它不
textfield
占位符中添加新行?比如:
comment1= [[[UITextField alloc]initWithFrame:frame2]autorelease];
comment1.placeholder = @"Write maximum 200 \r characters here";
UITextField
仅用于显示单行。如果要显示多行文本,必须使用UITextView
。或者,您可以使用UILabel
并设置“行数”属性。在iPhone中“\n”是新行字符。但是,它不适用于多行文本的UITextField
使用UITextView
UITextField没有任何属性或功能在其中创建新行。您可以改用UITextView。下面是代码示例
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@"\n"])
{ //Enter your code here }}
您可以改用UITextView吗?它们是为使用多行而设计的。除非你做一些毫无意义的疯狂的事情,否则不会。你只会浪费你的时间,你最好使用
UITextView
。