我想通过这种方式将localstringtextnote传递给Uploadviewcontroller,
UIViewController *controllerNew = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil owner:self];
controllerNew.localStringtextnote = localStringtextnote;
[self.navigationController pushViewController:controllerNew animated:YES];
[controllerNew release];
但我收到此错误“@property localstringtextnote不喜欢uiviewcontroller类型的对象” 要么 我想通过modalTransistionstyle
UploadViewController *aSecondViewController = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil];
aSecondViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:aSecondViewController animated:YES];
[UIView commitAnimations];
怎么做?提前谢谢。
答案 0 :(得分:2)
声明变量
NSString *_localStringtextnote;
在UploadViewController.h
档案中。
还在同一文件中为该变量添加属性。
@property(nonatomic,copy) NSString *localStringtextnote;
在.m文件中,在实现中合成它。
@synthesize localStringtextnote=_localStringtextnote;
现在运行应用程序。
答案 1 :(得分:1)
UploadViewController *controllerNew = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil owner:self];
controllerNew.localStringtextnote = localStringtextnote;
[self.navigationController pushViewController:controllerNew animated:YES];
[controllerNew release];
将uiview控制器更改为UploadViewController,因为uiview控制器没有任何属性localStringtextnote
答案 2 :(得分:0)
您必须在localStringtextnote
中将UploadViewController
声明为@property(nonatomic,retain)NSString * localStringtextnote;
,并在.m
文件中进行综合。
答案 3 :(得分:-1)
在controllerNew中创建一个新方法(不要忘记在* .h文件中声明它):
-(id) setParams:(NSString*)str {
localStringtextnote = [[NSString alloc] initWithString:str];
return self;
}
然后,当你需要puth这个视图控制器时:
UploadViewController *controllerNew = [[UploadViewController alloc] initWithNibName:@"UploadView" bundle:nil owner:self];
[self.navigationController pushViewController:controllerNew animated:YES];
controllerNew = [controllerNew setParams:localStringtextnote];
[controllerNew release];