2012-06-05 68 views
0

我有以下UIViewController類:從UIViewController中傳遞的值的UIView

FILE:ResultsDataViewController.h

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

FILE:ResultsDataViewController.m

#import "ResultsDataViewController.h" 

@interface ResultsDataViewController() 
@end 

@implementation ResultsDataViewController 
@synthesize data; 

然後我有我的UIView類名Plot.h/m

Plot.h:

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

Plot.m:

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

@end 

@implementation PlotGraph 
@synthesize receivedName; 

...

=====

問:

我該怎麼辦從我的UIViewController傳遞名稱的值並將其分配給變量receivedName在我的UIView?

UIView的情節是在我的UIViewController DataViewController

+2

'plotGraph.receivedName = self.name'; – beryllium

回答

0

視圖(注:@synthesize data;在你的問題可能是一個錯字,我會假設你的意思@synthesize name;此外,@interface Plot()也許應該@interface PlotGraph()。)

首先,您需要引用PlotGraph對象,或者將其作爲您在代碼中創建的內容,或者將其從xib文件或故事板加載到IBOutlet變量中。一旦你有,無論是你創建它或在viewDidLoad:,它只是這樣的:

plotView.receivedName = self.name; 
+0

謝謝菲利普!它工作很好魅力:)對不起,錯別字!乾杯!!! – Pupillam

相關問題