Đang chuẩn bị liên kết để tải về tài liệu:
Phát triển ứng dụng cho iPhone và iPad - part 12
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 12', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Implementing Search 79 FIGURE 3-7 Catalog with search interface FIGURE 3-8 Search in progress The UISearchDisplayController is initialized with a search bar and the View Controller containing the content to be searched. When a search begins the search display controller overlays the search interface above the original View Controller s view to display a subset of the original data. The results display is a table view that is created by the search display controller. The first step is to create the UISearchBar and add it to the table. In the RootViewController header add an instance variable and associated property for the search bar 0 interface RootViewController UITableViewController NSMutableArray products down oadon UISearchBar searchBar Wrox.com property retain nonatomic NSMutableArray products property retain nonatomic UISearchBar searchBar RootViewController.h In the RootViewController implementation file synthesize the searchBar synthesize searchBar You can now add the code to create the SearchBar and add it to the header of the TableView at the end of the viewDidLoad method Oil Create search bar self.searchBar UISearchBar alloc initWithFrame pliable lor CGRectMake 0.0f 0.0f 320.0f 44.0f autorelease Wrox.com self.tableView.tableHeaderView self.searchBar RootViewController.m 80 I CHAPTER 3 DISPLAYING YOUR DATA THE UITABLEVIEW Next you will create and configure the UISearchDisplayController. This controller will be used to filter and display the data in the RootViewController s TableView. In the header for RootViewController add an instance variable and associated property for the SearchDisplayController 0 interface RootViewController UITableViewController NSMutableArray products Available tar download on Wrox.com UISearchBar searchBar UISearchDisplayController searchcontroller property retain nonatomic NSMutableArray products property retain nonatomic UISearchBar searchBar property retain nonatomic UISearchDisplayController searchcontroller .