0

を表示しましたPopoverViewControllerが、フレームを正しく設定できません。ボタンをクリックすると、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)、このボタンの下にポップオーバーを表示し、ボタンを指す矢印マークを表示したいのですが、次のようになっています。

どうすれば入手できますか?

4

2 に答える 2

0

独自のポップオーバーを作成する代わりに、必要なすべてを処理する多くのカスタム ポップオーバーが既に利用可能です。リストは次のとおりです。シンプルで便利なWEPopOverを使用しました。プロジェクトで使用する前にライセンスを確認することを忘れないでください。

于 2013-02-21T06:29:34.277 に答える