2009-05-01 4 views
1

NIB 파일없이 프로그래밍 방식으로 UITableView를 작성합니다. 그러나 내 탐색 모음이 잘 나타나기 때문에 바보 같은 일을하고 있습니다. 내 UITableView도 마찬가지입니다. 그러나 UITableView 제대로 화면에 맞추고 있지 않습니다. UINavigationBar와 UITableView를 분리하면 약 20 픽셀이 보입니다.내 UITableView가 화면 경계를 차지하지 않는 이유는 무엇입니까?

enter image description here

가 여기에 문제 재현하는 코드이다 :이 스크린 샷에서 볼 수 있듯이 나는 검은 색으로 내 윈도우의 backgroundColor로 설정

- (void)loadView 
{ 
    [super loadView]; 
    // TableViews that wish to utilize tableView footers/headers should override this method. 

    UITableView *aTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 
    aTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); 
    aTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 

    aTableView.delegate = self; 
    aTableView.dataSource = dataSource; 

    self.tableView = aTableView; 
    [self.view addSubview:self.tableView]; 
    [aTableView release]; 

    // style navigation bar. 
    //self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque; 
}  

답변

1

사용 범위를 대신 applicationFrame

+0

을 그 그랬지,하지만 더 이해하고 싶다. applicationFrame이 화면을 차지하는 창에서 navigationBar을 뺀 것이라고 생각 했습니까? – Coocoo4Cocoa

+0

문제는 원점이며, aTableView는 self.view를 원점으로 사용하므로 사실 [self.view bounds]를 사용해야합니다. – CiNN

관련 문제