0
這是我用來顯示UIPickerView的方法,當按下按鈕時,我會用什麼方法解僱它?任何人有一個想法如何解僱這個DatePicker /子視圖
if (buttonIndex == 4) {
int height = 255;
//創建新的視圖
UIView * newView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 320, height)];
newView.backgroundColor = [UIColor colorWithWhite:1 alpha:1];
//添加工具欄
UIToolbar * toolbar = [[UIToolbar alloc] initWithFrame: CGRectMake(0, 0, 320, 40)];
toolbar.barStyle = UIBarStyleBlack;
//添加按鈕
UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:nil action:@selector(dismissCustom:)];
toolbar.items = [NSArray arrayWithObjects:infoButtonItem, nil];
//添加日期選取器
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDateAndTime ;
datePicker.hidden = NO;
datePicker.date = [NSDate date];
datePicker.frame = CGRectMake(0, 40, 320, 250);
[datePicker addTarget:self action:nil/*@selector(changeDateInLabel:)*/ forControlEvents:UIControlEventValueChanged];
[newView addSubview:datePicker];
//添加彈出視圖
[newView addSubview:toolbar];
[self.view addSubview:newView];
//它的動畫在屏幕上
CGRect temp = newView.frame;
temp.origin.y = CGRectGetMaxY(self.view.bounds);
newView.frame = temp;
[UIView beginAnimations:nil context:nil];
temp.origin.y -= height;
newView.frame = temp;
[UIView commitAnimations];
}
謝謝你,我會給你一個去!只是一個問題,什麼是新的塊形式?我會記住最後一點。 –
哦,我也沒有將自定義視圖類設置爲全部,因爲我只是在測試一些東西。我不小心把錯誤的代碼放進去了。 –
看看UIView的參考文檔。查看**下的方塊列表** – rmaddy