Tham dự Tech Lounge

Tham dự Tech Lounge


16. TableView

iThanh
5/8/2013 8:32Phản hồi: 7
16. TableView
TableView

Table nghĩa là bảng, đã nói đến bảng, bạn sẽ nghĩ ngay đến hoặc là nhiều dòng hoặc là nhiều cột.
Vậy TableView là một bảng có nhiều hàng mà Xcode cung cấp cho chúng ta để thiết kế những ứng dụng mang tính danh sách.

Giống như trong Setting của iPhone (hoặc iPad hoặc iPod) chúng ta cũng thấy một danh sách các lệnh.
Hoặc có thể thấy đơn giản trong ứng dụng AddressBook, đó cũng là một danh sách các tên, số điện thoại trong danh bạ của bạn.

Ở bài này, chúng ta sẽ hiển thị toàn bộ danh sách học sinh trong một lớp học.
Danh sách học sinh sẽ được đưa vào mảng (Array), TableView sẽ truy cập và lấy thông tin (như giá trị, số thứ tự của tên) và hiển thị ra cho người dùng nhìn thấy.

Với Video này, bạn sẽ hiểu ngay về TableView và có thể ứng dụng cùng với các đối tượng khác để tự mình làm các Apps đơn giản rồi đấy!

File: http://www.mediafire.com/folder/8egj1ebseezaw/Bài_16
7 bình luận
Chia sẻ

Xu hướng

Cảm ơn bạn Thanh 😃
iThanh cho mình hỏi. Như mình muốn thêm, sửa, xóa. Vậy hàm nào cho mình biết mình đang chọn cái row nào trên TableView.
Ví du: như bài của bạn mình chọn vào row đầu tiên " 1. Nguyễn Văn Mạnh ". Thì nó sẽ hiện lên ( label chãn hạn) là số "0" ( vì array chạy từ 0 mà ).
bác có tài liệu nào mà sử dụng api youtube ko thì share cho e xin vớiii 😁
Thanks!!!!
Cảm ơn bác 😁
- (UITableViewCell *)tableView😔UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

staticNSString *CellIdentifier = @"CellDanhSach";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

if (cell == nil) {

cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier];

}
NSString *Ten = [DanhSachLopobjectAtIndex:indexPath.row];

cell.textLabel.text = [NSStringstringWithFormat:mad:"%i", indexPath.row + 1];

cell.detailTextLabel.text = Ten;
return cell;

có pro nào giúp e giải thích đoạn code này đc không ạ?
cảm ơn trước pro
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView😔UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:mad:[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

khúc này là sao mà bị lược bỏ trong tableView vậy nhỉ?

Xu hướng

Bài mới









  • Chịu trách nhiệm nội dung: Trần Mạnh Hiệp
  • © 2024 Công ty Cổ phần MXH Tinh Tế
  • Địa chỉ: Số 70 Bà Huyện Thanh Quan, P. Võ Thị Sáu, Quận 3, TPHCM
  • Số điện thoại: 02822460095
  • MST: 0313255119
  • Giấy phép thiết lập MXH số 11/GP-BTTTT, Ký ngày: 08/01/2019