0

エラーが発生する理由は理解していますが、

'', reason: '-[UIPopoverController initWithContentViewController:] UIUserInterfaceIdiomPad で実行されていないときに呼び出されました.'

それを修正するのは少しトリッキーになっています。マイ ポップ オーバーは iPad でのみ必要で、iPhone バージョンでは必要ありません。iPhone のコードを省略してもif statement、クラッシュが発生しました。. ユニバーサルアプリだけでなくiPhoneでもビューを呼び出さなければならないと仮定して、単にペン先を呼び出しましたが、それもうまくいきif iphone statementませんでした。

 - (IBAction)popZs:(id)sender {  




if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

    if ([popoverController isPopoverVisible]) {
        [popoverController dismissPopoverAnimated:YES];
    } else {

        [self->popoverController setPopoverContentSize: CGSizeMake(601, 571)];

        [popoverController presentPopoverFromRect:((UIButton *)sender).bounds
                                           inView:sender
                         permittedArrowDirections:UIPopoverArrowDirectionUp
                                         animated:YES];

    }



}
else {

    /////using iPhone/////not sure how to handle this spart
     zsTablePop *pop = [[zsTablePop alloc] init];
    pop.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [pop presentModalViewController:pop animated:YES];



}

使用しているにもかかわらず、同じエラーが発生し続けるif ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

ポップオーバーの作成

.m


#import "ICCircuitDetails.h"
#import "zsTablePop.h"  ///////////////pop over xib/////

 @interface ICCircuitDetails ()



{
zsTablePop *controller;
UIPopoverController *popoverController;
}


 ///////more code/////////////


 - (id)initWithCircuit:(Circuit *)circuit
{


 self = [super initWithCertificate:circuit.distributionBoard.certificate];
if (self) {
    self.circuit = circuit;
    [[NSBundle mainBundle] loadNibNamed:@"ICCircuitDetails" owner:self options:nil];
    self.view.contentSize = CGSizeMake(self.contentView.frame.size.width,    self.contentView.frame.size.height);

 ///////////other code here/////////////////

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 

    controller = [[zsTablePop alloc] initWithNibName:@"zsTablePop" bundle:nil];
    popoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
4

1 に答える 1

1

エラーメッセージは、ポップオーバーをインスタンス化しようとしていることを示しています。コードはそれを提示することだけです。インスタンス化も処理する必要があります。

于 2012-10-04T22:33:23.263 に答える