-3

我每个都有四到五个视图控制器,它显示不完整的实现下面是一个视图控制器

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "CereniaAppDelegate.h"

@interface MainViewController : UIViewController  <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>{
    IBOutlet UIButton*homeButton;
    IBOutlet UIButton*economicDataButton;
    IBOutlet UIButton*riskButton;
    IBOutlet UIButton*financialImpactButton;
    IBOutlet UIButton*probabilitiesButton;
    IBOutlet UIButton*enterButton;
}



-(IBAction)enterButtonAction;
-(IBAction)homeButtonAction;
-(IBAction)economicDataButtonAction;
-(IBAction)riskButtonAction;
-(IBAction)financialImpactButtonAction;
-(IBAction)probabilitiesButtonAction;

@end

实施

#import "MainViewController.h"
#import "EconomicDataViewController.h"
#import "ProbabilitiesViewController.h"
#import "RiskViewController.h"
#import "FinancialImpactViewController.h"

@implementation MainViewController

-(IBAction)homeButtonAction{

}

-(IBAction)enterButtonAction{   
    EconomicDataViewController*targetContrlloer=[[EconomicDataViewController alloc] init];
    [self.navigationController pushViewController:targetContrlloer animated:YES];
}


-(IBAction)economicDataButtonAction{
    EconomicDataViewController*targetContrlloer=[[EconomicDataViewController alloc] init];
    [self.navigationController pushViewController:targetContrlloer animated:YES];
}



-(IBAction)riskButtonAction{
    RiskViewController*targetContrlloer=[[RiskViewController alloc] init];
    [self.navigationController pushViewController:targetContrlloer animated:YES];
}

-(IBAction)financialImpactButtonAction{
    FinancialImpactViewController*targetContrlloer=[[FinancialImpactViewController alloc] init];
    [self.navigationController pushViewController:targetContrlloer animated:YES];
}

-(IBAction)probabilitiesButtonAction{
    ProbabilitiesViewController*targetContrlloer=[[ProbabilitiesViewController alloc] init];
    [self.navigationController pushViewController:targetContrlloer animated:YES];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    return YES;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}

- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation {       
    // return YES;
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
}

- (void)didReceiveMemoryWarning {
   [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}

- (void)dealloc {   
    [super dealloc];

    [homeButton release];
    [economicDataButton release];
    [riskButton release];
    [probabilitiesButton release];
    [enterButton release];
}

@end
4

2 回答 2

1

这是因为您没有实现 UITextFieldDelegate、UITableViewDelegate、UITableViewDataSource 的委托方法。这样做,错误应该消失。

于 2013-02-09T05:56:29.913 回答
0

创建所有 UIButtons 的属性并在 .m 文件中 @synthesize 。

像:

MainViewController.h

@interface MainViewController : UIViewController  <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>{
    UIButton*homeButton;

}

@property(nonatomic,retain) IBOutlet UIButton *homeButton;


MainViewController.m

@synthesize homeButton;
于 2013-02-09T06:13:18.820 回答