IOS--UITextView 多行文本的輸入和顯示 的使用方法詳細

來源:互聯網
上載者:User

標籤:io   ar   color   os   使用   sp   on   資料   div   

IOS--UITextView 多行文本的輸入和顯示 的使用方法詳細 

// UITextView的常用方法 主要用來輸入和顯示多行文本資訊

    UITextView *oneTextView = [[UITextView alloc] init];

    oneTextView.frame = CGRectMake(0, 20, 320, 200); // 設定位置

    oneTextView.backgroundColor = [UIColor whiteColor]; // 設定背景色

    oneTextView.alpha = 1.0; // 設定透明度

    oneTextView.text = @"18331000747  [email protected] [email protected] www.baidu.com"; // 設定文字

    oneTextView.textAlignment = NSTextAlignmentCenter; // 設定字型對其方式

    oneTextView.font = [UIFont boldSystemFontOfSize:25.5f]; // 設定字型大小

    oneTextView.textColor = [UIColor redColor]; // 設定文字顏色

    [oneTextView setEditable:YES]; // 設定時候可以編輯

    oneTextView.dataDetectorTypes = UIDataDetectorTypeAll; // 顯示資料類型的串連模式(如電話號碼、網址、地址等)

    oneTextView.keyboardType = UIKeyboardTypeDefault; // 設定彈出鍵盤的類型

    oneTextView.returnKeyType = UIReturnKeySearch; // 設定鍵盤上returen鍵的類型

    oneTextView.scrollEnabled = YES; // 當文字寬度超過UITextView的寬度時,是否允許滑動

    

    [self.view addSubview:oneTextView]; // 添加到View上

    [oneTextView release], oneTextView = nil; // 釋放記憶體

    

    

    

    // 幾種常用的代理方法

    //將要開始編輯

    // - (BOOL)textViewShouldBeginEditing:(UITextView *)textView;

    

    //將要結束編輯

    // - (BOOL)textViewShouldEndEditing:(UITextView *)textView;

    

    //開始編輯

    // - (void)textViewDidBeginEditing:(UITextView *)textView;

    

    //結束編輯

    // - (void)textViewDidEndEditing:(UITextView *)textView;

    

    //內容將要發生改變編輯

    // - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;

    

    //內容發生改變編輯

    // - (void)textViewDidChange:(UITextView *)textView;

    

    //焦點發生改變

    // - (void)textViewDidChangeSelection:(UITextView *)textView;

  

IOS--UITextView 多行文本的輸入和顯示 的使用方法詳細

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.