2014-04-30 3 views
0

현재 사용자가 상호 작용할 때 사용자가 앱에 날짜와 시간을 입력해야하는 프로젝트를 만들고 있지만 표준 UIKit에 만족하지 않았습니다 UIDatePicker 보였고, 그렇게하려고 노력했다.루핑을 사용하여 UITableView와 사용자 정의 UIDatePicker 만들기

현재 사용자가 24 시간 이외의 시간을 지정했다면 UITableView 님의 요일, 시간, 분 및 선택적으로 AM/PM을 유지하는 기능이 제대로 작동합니다.

내가 붙어있는 비트는 보통의 것처럼 테이블 뷰가 옵션을 반복하는 것입니다. UIDatePicker. UITableView으로이 효과를 만드는 데 사용할 수있는 기법이 있습니까?

또한 간략하게는 UIPickerView을 들여다 보았지만, 루핑의 기능이 tableView보다 더 쉽고/더 어려울 지 확신 할 수 없습니다. 내가 뭘하는 표준 방법이 있다고 생각하지 않습니다 Clear Date Picker

답변

0

: 그의 디자인은 예를 들어

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated 

사용자 정의 할 수있어, 클리어의 최신 업데이트는 사용자 정의 날짜 선택의 구현이 이. 어쩌면 당신은 tableview의 scrollView 내용 오프셋을 확인하고 원하는 위치로 점프하도록 조정할 수 있습니다.

올바르게 작동하면 점프를 볼 수 없으므로 셀 수를 복제해야합니다. 그것이 가장 좋은 방법이지만,이 코드가 작동하는 경우

확실하지, 그것을 시도 :

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.tableView.dataSource = self; 
    self.tableView.delegate = self; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return numberOfCells*2; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"myCell"]; 
    if(!cell) { 
     cell = [[UITableViewCell alloc] init]; 
    } 

    cell.textLabel.text = [NSString stringWithFormat:@"Cell N: %d", indexPath.row%numberOfCells]; 

    return cell; 
} 

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
    if((scrollView.contentOffset.y+scrollView.frame.size.height)>=scrollView.contentSize.height) { 
     scrollView.contentOffset = CGPointMake(0, scrollView.contentSize.height/2-scrollView.frame.size.height); 
    } 

    if(scrollView.contentOffset.y<=0) { 
     scrollView.contentOffset = CGPointMake(0, scrollView.contentSize.height/2); 
    } 
} 
관련 문제