Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone



Clound SSD Virtual Server

iOS/iPhone Text View (UITextView) Display Multiline Text Region (Objective-C, iPhone, iPad)

iOS/iPhone Text View (UITextView) Display Multiline Text Region (Objective-C, iPhone, iPad) ในกรณีที่เราต้องการแสดงรายละเอียดข้อความต่าง ๆ ที่เป็น Detail หรือ Description บนหน้าจอของ iPhone หรือ iPad เราจะไม่สามารถใช้ Object ของ Label ได้ เพราะ Label จะถูกมองเป็น Line หรือบรรทัดเท่านั้น ไม่สามารถแสดงข้อความ ที่ต้องการรายละเอียดเช่น บทความ แต่เราจะใช้ Object ที่ชื่อว่า Text View ซึ่งเป็น Object ที่สามารถใช้งานได้ง่าย ๆ เหมือน ๆ กับ Label

iOS/iPhone Text View (UITextView) Display Multiline Text Region

iOS/iPhone Text View (UITextView) Display Multiline Text Region


ในการสร้าง Text View จะใช้สำหรับสดง Detail หรือ Description จากข้อมูลต่าง ๆ โดยสามารถกำหนดได้ค่าที่เป็น Static Content และ ค่าที่มาจาก Dynamic Content ผ่านการเขียน Code ด้วยภาษา Objective-C ได้ เรามาดูตัวอย่างแบบง่าย ๆ

iOS/iPhone Text View (UITextView) Display Multiline Text Region

เริ่มต้นการสร้าง Application แบบง่าย ๆ ด้วย Single View Application

iOS/iPhone Text View (UITextView) Display Multiline Text Region

เลือกและไม่เลือกดังรูป

iOS/iPhone Text View (UITextView) Display Multiline Text Region

ตอนนี้เรามีหน้าจอ View เปล่า ๆ ว่าง ๆ

iOS/iPhone Text View (UITextView) Display Multiline Text Region

ให้ลาก Object ของ TextView มาว่างไว้ที่ View จัดรูปแบบและขนาดตามตำแหน่งที่ต้องการ








iOS/iPhone Text View (UITextView) Display Multiline Text Region

ได้ TextView ที่เป็น Static เรียบรร้อยแล้ว เราสามารถเขียนข้อความเพิ่มได้ทันที ด้วยการคลิกที่ Inspector ของ Object แล้วจะมีช่องให้ใส่ข้อความต่าง ๆ ลงไป

iOS/iPhone Text View (UITextView) Display Multiline Text Region

หรือจะทำแบบ Dynamic ด้วยการเชื่อม IBOutlet

iOS/iPhone Text View (UITextView) Display Multiline Text Region

จากนั้นในฟล์ .m ก็เรียกและกำหนดค่าดังรูปได้ในทันที Code ทั้งหมดดังนี้

ViewController.h
//
//  ViewController.h
//
//  Created by Weerachai on 11/4/55 BE.
//  Copyright (c) 2555 Weerachai. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    IBOutlet UITextView *myTextView;
}

@end


ViewController.m
//
//  ViewController.m
//
//  Created by Weerachai on 11/4/55 BE.
//  Copyright (c) 2555 Weerachai. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    myTextView.text = @"text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ";
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [myTextView release];
    [super dealloc];
}
@end









Screenshot

iOS/iPhone Text View (UITextView) Display Multiline Text Region

แสดงข้อความ Text ต่าง ๆ เหมือนในภาพ

iOS/iPhone Text View (UITextView) Display Multiline Text Region

แต่เราจะเห็นว่าตอนนี้มันสามารถที่จะ Edit ข้อความได้

iOS/iPhone Text View (UITextView) Display Multiline Text Region

ถ้าไม่ต้องการให้แก้ไขข้อความได้ ก็ปิดมันซะ

สำหรับ TextView อาจจะเป็น Object ตัวหนึ่งที่เราอาจจะต้องใช้บ่อย ๆ เช่นเดียวกับ Label เช่นการแสดงรายละเอียด หรือข้อความต่าง ๆ ทั้งแบบ Static Content และแบบ Dynamic Content


.

   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2012-11-07 10:37:45 / 2017-03-26 09:57:59
  Download : Download  iOS/iPhone Text View (UITextView) Display Multiline Text Region (Objective-C, iPhone, iPad)
 Sponsored Links / Related

 
Objective-C กับการสร้าง Event และ Action (IBAction) โต้ตอบ บน iOS (iPhone,iPad)
Rating :

 
Objective-C และ Outlet (IBOutlet) Action(IBAction) แบบง่าย ๆ ผ่าน Xcode (iPhone,iPad)
Rating :

 
รู้จัก IBOutlet และ IBAction กับ Interface Builder (iOS , iPhone , iPad)
Rating :

 
iOS/iPhone Label(UILabel) , Text Field(UITextField) , Round Rect Button(UIButton) Example (iPhone,iPad)
Rating :

 
สุดยอดการใช้ Object Library เครื่องมือ สร้างออกแบหน้าจอ Interface Builder ในรูปแบบต่าง ๆ ของ iOS ทั้งหมด
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่