0

次の UIViewController クラスがあります。

ファイル: ResultsDataViewController.h

@interface ResultsDataViewController : UIViewController
@property (nonatomic, strong) NSString* name;
@end

ファイル: ResultsDataViewController.m

#import "ResultsDataViewController.h"

@interface ResultsDataViewController ()
@end

@implementation ResultsDataViewController
@synthesize data;

次に、クラス名 Plot.h/m の UIView があります

プロット.h:

@interface PlotGraph : UIView <CPTBarPlotDataSource, CPTBarPlotDelegate>
@property (nonatomic, strong) NSString* receivedName;
@end

プロット.m:

#import "Plot.h"
@interface Plot()

@end

@implementation PlotGraph
@synthesize receivedName;

...

=====

質問:

UIViewController から name の値を渡し、それを UIView の変数 receivedName に割り当てるにはどうすればよいですか?

UIView Plot は、私の UIViewController DataViewController のビューです

4

1 に答える 1

0

(注:@synthesize data;あなたの質問はおそらくタイプミスです。私はあなたが意味したと仮定します@synthesize name;。また、@interface Plot()おそらくそうあるべき@interface PlotGraph()です。)

まず、PlotGraphオブジェクトへの参照を、コードで作成するかIBOutlet、xib ファイルまたはストーリーボードから変数にロードするものとして持つ必要があります。作成した場所または でそれを取得したら、viewDidLoad:次のようになります。

plotView.receivedName = self.name;
于 2012-06-05T11:18:48.110 に答える