iOS - NavController&自定义视图

时间:2011-08-08 20:49:09

标签: ios ipad uiviewcontroller uinavigationcontroller

崩溃:

- [UIImageView setParentViewController:]:无法识别的选择器发送到实例0x58701e * 因未捕获的execption'NSInvalidArgumentExecption'而终止应用程序,原因:' - [UIImageView setParentViewController:]:无法识别的选择器发送到实例0x58701e0'

当我尝试推送没有IB的自定义UIViewController时会发生这种情况。

当我使用IB执行此操作时,它可以正常工作,但这并不是我需要的。

为我的代表召集的是什么

-(void)switchToTrailerOne 
{
CGsize screenSize = [UIScreen mainScreen].bounds.size;
CGRect screenBounds = CGRectMake(0, 0, ScreenSize.width, screenSize.height);
TrailersViewController *trailersController = [[TrailersViewController alloc] initWithFrame:screenBounds];

[self.navController pushViewController:trailersController animated:NO]; (Crashes on this line)

[trailersController gotoFirstTrailer];
}

问我任何其他代码,因为我几乎从不远离comp一次超过一小时。

编辑:你感兴趣的任何特定部分的文件有点长吗?我会发布一些我认为可能会出现的情况......

-(void)loadView{

    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    CGRect screenBounds = CGRectMake(0, 0, screenSize.width, screenSize.height);
    myTrailersView = [[UIImageView alloc] initWithFrame:screenBounds];
    myTrailersView.autoresizesSubviews = YES;
    self.view = myTrailersView;
}

//Initiation Method
- (void)viewDidLoad {
    [super viewDidLoad];

    //self.myTrailersView.frame = self.view.frame;

    //Turn User Interaction ON - UI Image Views are Off By Default
    myTrailersView.userInteractionEnabled = YES;

    //Set Position Counters to starting values
    currentNode              = 0;
    currentPosition          = 0;

    //Allocate the Node Collection
    nodeCollection           = [NodeSet alloc];

    //Copy the Node Collection to the Receiver Array
    nodeArray                = nodeCollection.createNodeList;

    //Done With Node Collection Release it
    [nodeCollection release];

    //
    //Create the button that launches the cutaway view
    //
    UIBarButtonItem *rotationButton = [[UIBarButtonItem alloc] initWithTitle:@"Cutaway View" 
                                                                       style:UIBarButtonItemStylePlain 
                                                                      target:self 
                                                                      action:@selector(gotoRotationView)];
    self.navigationItem.rightBarButtonItem = rotationButton;
    [rotationButton release];

    ////////Setup the Swipe Forward Recognizer////////

    UISwipeGestureRecognizer *recognizerUp;

    recognizerUp             = [[UISwipeGestureRecognizer alloc]
                    initWithTarget:self action:@selector(handleSwipeFrom:)];

    [recognizerUp setDirection:(UISwipeGestureRecognizerDirectionUp)];
    [myTrailersView addGestureRecognizer:recognizerUp];
    [recognizerUp release];

    ////////Setup the Swipe Backward Recognizer////////

    UISwipeGestureRecognizer *recognizerDown;

    recognizerDown            = [[UISwipeGestureRecognizer alloc] 
                                    initWithTarget:self action:@selector(handleSwipeFrom:)];

    recognizerDown.direction  = UISwipeGestureRecognizerDirectionDown;
    [myTrailersView addGestureRecognizer:recognizerDown];
    [recognizerDown release];

    ////////Setup the Swipe Left Recognizer////////

    UISwipeGestureRecognizer *recognizerLeft;

    recognizerLeft            = [[UISwipeGestureRecognizer alloc] 
                                    initWithTarget:self action:@selector(handleSwipeFrom:)];

    recognizerLeft.direction  = UISwipeGestureRecognizerDirectionLeft;
    [myTrailersView addGestureRecognizer:recognizerLeft];
    [recognizerLeft release];

    ////////Setup the Swipe Right Recognizer////////

    UISwipeGestureRecognizer *recognizerRight;

    recognizerRight           = [[UISwipeGestureRecognizer alloc] 
                                    initWithTarget:self action:@selector(handleSwipeFrom:)];

    recognizerRight.direction = UISwipeGestureRecognizerDirectionRight;
    [myTrailersView addGestureRecognizer:recognizerRight];
    [recognizerRight release];
}

- (id)initWithFrame:(CGRect)frame {
    self = [super.view initWithFrame:frame];

    return self;
}

1 个答案:

答案 0 :(得分:1)

看起来好像是在尝试推送自定义UIView而不是自定义UIViewController。检查TrailersViewController类层次结构。