我想将工具栏和选择器视图作为 popovercontroller 的子视图,为此我执行以下操作,到目前为止,我的选择器视图显示完美,但在上面我还想显示我的工具栏,其中有一个名为 Done 的按钮如果您发现我做错了什么,请指导我
- (IBAction)setAlarm:(id)sender {
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 344)];
popoverView.backgroundColor = [UIColor whiteColor];
[popoverView addSubview:toolbar];
[popoverView addSubview:timePicker];
timePicker.hidden = NO;
toolbar.hidden = NO;
popoverContent.view = popoverView;
//resize the popover view shown
//in the current view to the view's size
popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 216);
//create a popover controller
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
timePicker.frame = popoverView.bounds;
toolbar.frame = popoverView.bounds;
CGRect popoverRect ;
popoverRect.origin.x =591;
popoverRect.origin.y = 139;
popoverRect.size.height = 95;
popoverRect.size.width = 44;
[popoverController presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
//release the popover content
[popoverView release];
[popoverContent release];
timePicker.hidden = NO;
toolbar.hidden = NO;
}