- (IBAction)无法正常工作

时间:2013-01-30 02:28:59

标签: iphone xcode button ibaction

我试图制作,当按下按钮时,它将转到下一页这里是代码,但没有任何事情发生。我把断点看看它是否会在那里得到它确实存在。在某些时候,它正在工作,然后神奇地发生了一些事情,现在它不再起作用了。任何帮助都感激不尽。

    //
//  MainViewController.m
//  SimpleApp
//
//  Created by Ruslan on 1/28/13.
//  Copyright (c) 2013 Company. All rights reserved.
//

#import "MainViewController.h"
#import "AppDelegate.h"
#import "EditViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController



// Call this when take photo button is pressed





- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    // Show Camera




}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.


}


// Call this when ipmport button is pressed

-(IBAction)importButton:(id)sender
{
    EditViewController *editPage = [[EditViewController alloc] initWithNibName:@"EditViewController" bundle:nil];
    [self.navigationController pushViewController:editPage animated:(YES)];
//    EditViewController *editPage = [[EditViewController alloc] initWithNibName:@"EditViewController" bundle:nil];
//    [self.navigationController pushViewController:editPage animated:(YES)];

}



@end

1 个答案:

答案 0 :(得分:0)

快速修复:

[self presentViewController:editPage animated:YES completion:nil];

或者,您需要考虑您的观点如何组合在一起。是否应该使用按钮从视图中“推送”编辑页面(因此它会得到一个“后退”箭头)?如果是,则按住按钮的视图需要位于导航控制器内,这意味着无论谁呈现视图都会将其包装为导航等...