我已显示 aPopoverViewController
但无法正确设置其框架。当我单击一个按钮时,我PopoverViewController
将显示。
-(IBAction)AddTheTimePicker:(id)sendar {
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
UIButton *button = (UIButton *)sendar;
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView *popoverView = [[[UIView alloc] init]autorelease]; //view
popoverView.backgroundColor = [UIColor blackColor];
DatePicker=[[[UIDatePicker alloc]init]autorelease];//Date picker
DatePicker.frame=CGRectMake(0,44,320, 216);
DatePicker.datePickerMode = UIDatePickerModeDate;
[DatePicker setTag:10];
UIToolbar *pickerDateToolbar = [[[UIToolbar alloc] initWithFrame:[self isViewPortrait]?CGRectMake(0, 0, 320, 44):CGRectMake(0, 0, 320, 44)]autorelease];
pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerDateToolbar sizeToFit];
NSMutableArray *barItems = [[[NSMutableArray alloc] init]autorelease];
UIBarButtonItem *doneBtn = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dateChanged:)]autorelease];
[barItems addObject:doneBtn];
UIBarButtonItem *flexSpace = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]autorelease];
UILabel *toolBarItemlabel;
if([self interfaceOrientation] == UIInterfaceOrientationPortraitUpsideDown || [self interfaceOrientation] == UIInterfaceOrientationPortrait)
toolBarItemlabel= [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 180,30)]autorelease];
else
toolBarItemlabel = [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200,30)]autorelease];
[toolBarItemlabel setTextAlignment:UITextAlignmentCenter];
[toolBarItemlabel setTextColor:[UIColor whiteColor]];
[toolBarItemlabel setFont:[UIFont boldSystemFontOfSize:16]];
[toolBarItemlabel setBackgroundColor:[UIColor clearColor]];
UIBarButtonItem *buttonLabel =[[[UIBarButtonItem alloc]initWithCustomView:toolBarItemlabel]autorelease];
[barItems addObject:buttonLabel];
[barItems addObject:flexSpace];
UIBarButtonItem *SelectBtn = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(DatePickercancelClick:)]autorelease];
[barItems addObject:SelectBtn];
[pickerDateToolbar setItems:barItems animated:YES];
[popoverView addSubview:DatePicker];
[popoverView addSubview:pickerDateToolbar];
popoverContent.view = popoverView;
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
popoverController.delegate=self;
[popoverContent release];
[popoverController setPopoverContentSize:CGSizeMake(320, 264) animated:NO];
[popoverController presentPopoverFromRect:[sendar frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
}
UIButton
的框架是(450,285,80 30)
。我想在此按钮下方显示弹出框,并带有指向按钮的箭头标记。但我得到了这样的:
我怎么才能得到它?