【发布时间】:2010-03-05 18:22:29
【问题描述】:
我有一个问题,我想从另一个控制器调用一个视图控制器中定义的函数。 我尝试了似乎有一百种不同的设置,但似乎没有任何效果。
我已经发布了基本代码,希望有人能告诉我他们将如何做到这一点。 基本上我想做的就是调用 SwitchViewController 中定义的 MYBPress 函数 按下 dealB 按钮时的 GameViewController。任何帮助将不胜感激。 PS:我已经编码了很长时间,但对 Obj-C 来说真的很陌生
// ------- SwitchViewController.h ---------------
#import <UIKit/UIKit.h>
@class GameViewController;
@class OptionsViewController;
@interface SwitchViewController : UIViewController {
OptionsViewController *optionsViewController;
}
@property ( retain, nonatomic ) OptionsViewController *optionsViewController;
@property ( retain, nonatomic ) GameViewController *gameViewController;
-(IBAction)MyBPress:(id)sender;
@end
// -------- GameViewController.h ------------
#import <UIKit/UIKit.h>
@interface GameViewController : UIViewController {
IBOutlet UIButton *dealB;
}
@property(nonatomic,retain) IBOutlet UIButton *dealB;
- (IBAction)dealB:(id)sender;
@end
// ------- GameViewController.m
#import "GameViewController.h"
@implementation GameViewController
@synthesize dealB; // The Deal button
- (IBAction)dealB:(id)sender
{
// Here is where I want to call the MyBPress function
}
@end
【问题讨论】:
标签: iphone objective-c function uiviewcontroller call