2011-10-11 29 views
5

Tôi đã tạo phương thức - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { cho UITableViewCellAccessoryDetailDisclosureButton.Có sự khác biệt nào giữa UITableViewCellAccessoryDetailDisclosureButton và UITableViewCellAccessoryDisclosureIndicator

Bây giờ tôi muốn sử dụng UITableViewCellAccessoryDisclosureIndicator thay cho UITableViewCellAccessoryDetailDisclosureButton.

Có sự khác biệt nào giữa UITableViewCellAccessoryDetailDisclosureButtonUITableViewCellAccessoryDetailDisclosureButton không?

Trả lời

2

Có sự khác biệt. UITableViewCellAccessoryDetailDisclosureButton thực sự là một nút nhưng UITableViewCellAccessoryDisclosureIndicator thì không.

Bạn có thể sử dụng UITableViewCellAccessoryDisclosureIndicator thay vì UITableViewCellAccessoryDetailDisclosureButton nhưng bạn không thể có được tableView: accessoryButtonTappedForRowWithIndexPath: phương pháp gọi khi bạn gõ vào UITableViewCellAccessoryDisclosureIndicator vì nó không phải là một nút.

+0

làm thế nào tôi có thể gọi tableView: accessoryButtonTappedForRowWithIndexPath: phương pháp bằng cách sử dụng UITableViewCellAccessoryDisclosureIndicator ??? ... hoặc làm thế nào tôi có thể sử dụng nút tùy chỉnh trên UITableViewCellAccessoryDetailDisclosureButton để nó có thể thực hiện hành động bằng cách chạm vào nó .. ?? – Varsha

+0

Tạo một nút với mục tiêu/hành động và gán nó làm chế độ xem phụ kiện. Bỏ qua phương thức tableView: accessoryButtonTappedForRowWithIndexPath:. – EmptyStack

+0

bạn có thể giải thích nó không ??, ... làm cách nào tôi có thể thêm nút trên UITableViewCellAccessoryDetailDisclosureButton ??? .. – Varsha

6

Apple HIG khuyên bạn nên sử dụng UITableViewCellAccessoryDisclosureIndicator để điều hướng thông qua dữ liệu phân cấp và UITableViewCellAccessoryDetailDisclosureButton để thực hiện một số hành động, có thể hiển thị chế độ xem chỉnh sửa có thể thay đổi dữ liệu. Tuy nhiên, hầu hết các lập trình viên dường như bỏ qua điều này.

Bạn có thể thực hiện các phương pháp đại biểu tableView:didSelectRowAtIndexPath: như thế này:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { 
    [self tableView:tableView didSelectRowAtIndexPath:indexPath]; 
} 

Hoặc ngược lại.

0

Có, chúng khác nhau.

Sử dụng UITableViewCellAccessoryDetailDisclosureButton khi người dùng nhấn vào nút màu xanh lam thực hiện một hành động khác với thao tác chạm vào phần còn lại của hàng, ngay cả khi phần còn lại của hàng không làm gì cả.

Sử dụng UITableViewCellAccessoryDisclosureIndicator khi toàn bộ hàng có thể nhấn và tạo ra cùng một hành động.

Nếu hành vi của bạn là gì đó khác, hãy sử dụng một số cơ chế khác.

Các vấn đề liên quan