1

以下のコードを使用して、NSString値を「webwhatsnew」サブビューに渡すにはどうすればよいですか。ありがとう

-(IBAction)Whatsnew {
  NSString *myString =[URL absoluteString]; 
  // how can I pass this value to "webwhatsnew" subview 
  webwhatsnew = [[WebWhatsnewView alloc]initWithNibName:@"WebWhatsnewView"bundle:nil]; 
  [self.view addSubview:webwhatsnew.view];
}
4

3 に答える 3

2

WebWhatsnewView で NSString プロパティを作成します。次に、それに値を設定します。例:

//WebWhatsnewView.h
...
@property (nonatomic, retain) NSString *someString;
...

-(IBAction)Whatsnew {
  NSString *myString =[URL absoluteString]; 
  webwhatsnew = [[WebWhatsnewView alloc]initWithNibName:@"WebWhatsnewView"bundle:nil]; 
  webwhatsnew.someString = myString; //if myString is a string that you want to pass
  [self.view addSubview:webwhatsnew.view];
}

それが役に立てば幸い

編集

//WebWhatsnewView.m
...
@synthesize someString;
...
于 2012-04-13T07:31:07.553 に答える
2

に文字列プロパティ/エンティティが必要ですWebWhatsnewView。に設定できるように

webwhatsnew.<your_string_entity> = myString;

必ず合成してください。

于 2012-04-13T07:34:41.893 に答える