- (void)loadView
{
SettingsTitleBar=[[UINavigationController alloc] initWithRootViewController: self];
searchBar =[ [UISearchBar alloc] initWithFrame:CGRectMake(0, 44, 320, 40)];
searchBar.placeholder = @"Type your City Name";
searchBar.delegate = self;
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
[searchBar setShowsCancelButton:YES];
[SettingsTitleBar.navigationBar addSubview:searchBar];
self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 85, 320, 392)];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 120, 320, 302) style: UITableViewStyleGrouped];
[tableView setDelegate:self];
[tableView setDataSource:self];
[self.view addSubview:tableView];
}
나는 UITableViewController가 있습니다. 제목 표시 줄에 처음 44 픽셀 높이를 사용하고 검색 막대 높이의 다음 40 픽셀을 사용했습니다 (44 + 40). 이것은 탐색 컨트롤러 하위보기로 추가됩니다. 다음 나는 상단에서 85 픽셀에서 내 self.view 추가, 마침내 tableview self.view 자식으로 추가되었습니다. 그러나 표보기가 검색 막대와 겹쳐졌습니다. 나는 그걸 잘못 생각하지 않아. tableview 및 self.view 다양한 yPositions 변경하려고했지만 여전히 아무 일도 발생하지 않았습니다. 누구든지이 일에서 나를 도울 수 있습니까?UITableView를 배치 할 수 없습니다?
참고 : UITableviewHeader 섹션에 SearchBar를 추가하고 싶지 않습니다.
작동하지 않았 음 – muthukumar
검색 표시 줄을 견고한 위치에 고정해야합니다. 그렇게하면 표보기와 함께 스크롤됩니다. – muthukumar
이 프레임을 사용해보십시오 self.view.frame = CGRectMake (0,0,320,436); searchbar.frame = CGRectMake (0,0,320,44); tableview.frame = CGRectMake (0,44,320,392); [self.view addSubview 검색 창]; [self.view addSubview tableview]; –