tailieunhanh - Phát triển ứng dụng cho iPhone và iPad - part 12
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 property retain nonatomic NSMutableArray products property retain nonatomic UISearchBar searchBar 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 UISearchBar alloc initWithFrame pliable lor CGRectMake autorelease 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 UISearchBar searchBar UISearchDisplayController searchcontroller property retain nonatomic NSMutableArray products property retain nonatomic UISearchBar searchBar property retain nonatomic UISearchDisplayController searchcontroller .
đang nạp các trang xem trước