9.21. The use of IOS text views

发布时间 : 2025-10-25 13:32:33 UTC      

Page Views: 9 views

The text view is used to display text with multiple lines of scrolling.

9.21.1. Important attribute

  • DataDetectorTypes

  • Delegate

  • Editable

  • InputAccessoryView

  • InputView

  • Text

  • TextAlignment

  • TextColor

An important delegation method

-(void)textViewDidBeginEditing:(UITextView *)textView 
-(void)textViewDidEndEditing:(UITextView *)textView 
-(void)textViewDidChange:(UITextView *)textView 
-(BOOL)textViewShouldEndEditing:(UITextView *)textView 

Add a custom method addTextView

-(void)addTextView{ myTextView = [[UITextView alloc]initWithFrame: CGRectMake(10, 50, 300, 200)]; [myTextView setText:@"Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aiqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."]; myTextView.delegate = self; [self.view addSubview:myTextView]; } 

Perform a textView delegate in ViewController.m

#pragma mark - Text View delegates -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange: (NSRange)range replacementText:(NSString *)text{ if ([text isEqualToString:@"\n"]) { [textView resignFirstResponder]; } return YES; } -(void)textViewDidBeginEditing:(UITextView *)textView{ NSLog(@"Did begin editing"); } -(void)textViewDidChange:(UITextView *)textView{ NSLog(@"Did Change"); } -(void)textViewDidEndEditing:(UITextView *)textView{ NSLog(@"Did End editing"); } -(BOOL)textViewShouldEndEditing:(UITextView *)textView{ [textView resignFirstResponder]; return YES; } 

Modify the viewDidLoad method in ViewController.m, as shown below

(void)viewDidLoad { [super viewDidLoad]; [self addTextView]; } 

9.21.2. Result output

Now when we run the application, we will see the following output

textViewOutput

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。