我有两个问题:
- 我的 iPhone 屏幕上有一个搜索栏。当我滚动屏幕时,我的搜索栏也会滚动。我想解决这个问题或让它成为绝对。
- 搜索不像如果我输入 A 那么我应该得到所有以字母 A 开头的单词。
我正在尝试的代码:
- (void)viewDidLoad {
[super viewDidLoad];
const NSInteger searchBarHeight = 45;
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0,
self.tableView.frame.size.width, searchBarHeight)];
searchBar.delegate = self;
self.tableView.tableHeaderView = searchBar;
[searchBar release];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Refresh"
style:UIBarButtonItemStyleBordered target:self action:@selector(onAddContact:)];
self.navigationItem.rightBarButtonItem = addButton;
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor]; // change this color
self.navigationItem.titleView = label;
label.text = NSLocalizedString(@"All Contacts", @"");
[label sizeToFit];
content = [DataGenerator wordsFromLetters];
indices = [[content valueForKey:@"headerTitle"] retain];
}