2017-09-20 4 views
0

새로운 iPhone X에서 테스트 할 때까지 내 장치가 모든 장치에서 잘 보입니다 (첨부 된 스크린 샷 참조). 검색 창은 탐색 바 아래에 있으며 끔찍합니다. 새로운 안전한 영역 인세 트 인 edgesForExtendedLayout을 사용해 보았지만 성공하지 못했습니다. 어쩌면 누군가가이 문제를 도울 수 있습니다.iPhone X의 뷰 위치가 잘못되었습니다.

enter image description here

답변

0

일부 조사를 마친 후 문제를 해결하는 방법을 알아 냈습니다. 안전 영역에 따라 검색보기를 정렬해야했습니다. 아래 솔루션을 참조하십시오.

if (@available(iOS 11.0, *)) 
{ 
    [self.searchView setTranslatesAutoresizingMaskIntoConstraints:NO]; 
    UILayoutGuide *guide = self.view.safeAreaLayoutGuide; 

    [NSLayoutConstraint activateConstraints:@[ 
               [self.searchView.topAnchor constraintEqualToAnchor:guide.topAnchor], 
               [self.searchView.leadingAnchor constraintEqualToAnchor:guide.leadingAnchor], 
               [self.searchView.trailingAnchor constraintEqualToAnchor:guide.trailingAnchor], 
               [NSLayoutConstraint constraintWithItem:self.searchView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44] 
               ]]; 
    } 

이제는 모든 장치에서 모든 것이 잘 어울립니다. 희망이 비슷한 문제를 가진 다른 사람을 도울 수 있기를 바랍니다. 건배.

0

short videos Apple posted about iPhone X (and 8 and 8 Plus) development 주소 (그것은 매우 가까운 또는 부부)이 정확한 상황.

iPhone X 용 WWDC 앱을 적용한 사례 연구에서 they find that the search bar isn't set up right in the Videos tab. 이는 presentUISearchController이 들어 있기 때문입니다.하지만 iOS 11 (모든 기기 용)에서이를 처리하는 가장 좋은 방법은 탐색 컨트롤러에 탐색 컨트롤러를 대신 연결하는 것입니다. 당신은 여전히 ​​아이폰 OS 10 (또는 이전)에 다시 전개해야하는 경우, 당신은 가용성 검사에서이 문제를 처리 할 수 ​​

let searchController = UISearchController(searchResultsController: nil) 
// configure searchController properties 

if #available(iOS 11.0, *) { 
    self.navigationItem.searchController = searchController 
    searchController.isActive = true // to show it now 
} else { 
    present(searchController, animated: true, completion: nil) 
} 

을 마찬가지로, 직접 테이블보기의 헤더로 검색 창을 설정하는 경우, you can attach it to the navigation item instead there, too :

if #available(iOS 11.0, *) { 
    self.navigationItem.searchController = searchController 
    searchController.isActive = shouldShowBarNow // made up local variable 
} else { 
    if shouldShowBarNow { 
     self.tableView.tableHeaderView = searchController.searchBar 
    } else { 
     self.tableView.tableHeaderView = nil 
    } 
} 
관련 문제