2012-01-19 2 views
1

이 코드를 사용하여 datePicker를 표시하고 있습니다. textField를 클릭하면 나타납니다. 그러나 "닫기"버튼은 DatePicker를 덮어 씁니다. 조금 아래로 움직이는 방법을 아십니까? 미리 감사드립니다.iPhone DatePicker with Actionsheet

-(IBAction)acsheet:(id)sender{ 

actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
              delegate:nil 
           cancelButtonTitle:nil 
          destructiveButtonTitle:nil 
           otherButtonTitles:nil]; 

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; 

//CGRect pickerFrame = CGRectMake(0, 45, 0, 0); 
pickerView1 = [[UIDatePicker alloc] init]; 
pickerView1.datePickerMode = UIDatePickerModeDate; 



[actionSheet addSubview:pickerView1]; 

UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]]; 
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); 
closeButton.segmentedControlStyle = UISegmentedControlStyleBar; 
closeButton.tintColor = [UIColor blackColor]; 
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged]; 
[actionSheet addSubview:closeButton]; 
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];  
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)]; 

[pickerView1 addTarget:self 
      action:@selector(updateLabel:) 
    forControlEvents:UIControlEventValueChanged]; 
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissDatePicker:)] ; 
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height, 320, 44)]; 
toolBar.tag = 11; 
toolBar.barStyle = UIBarStyleBlackTranslucent; 

[toolBar setItems:[NSArray arrayWithObjects:spacer, doneButton, nil]]; 
[self.view addSubview:toolBar]; 



} 

답변

1
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); 

변화는 7.0f 및 30.f더 긍정적 values.and는 시도.

7.0f 값은 당신이 UITextField 첫 번째 응답자 될 때 UIDatePicker를 표시 할 경우 // increase it to shift the button lower

30.f 값이 버튼 // increase it by the same amount you increase origin to keep proportional height

8

의 size.height입니다 버튼의 origin.y입니다 날짜 선택 도구를 텍스트 필드의 inputView으로 설정해야합니다. 그런 다음 필드를 누르면 날짜 선택 도구가 키보드 대신 위로 슬라이드됩니다.

0

나는 혼자 힘으로 해결했습니다.

pickerView1 = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 450)]; 
이에

pickerView1 = [[UIDatePicker alloc] init]; 

:

은 내가이 줄을 변경했습니다