我很难将数据从UIContainerView获取到另一个UIContainerView。例如:我有两个容器,它们是calculatorContainer和displayResultContainer。因此,当我按"=“按钮来计算结果时,我希望它出现在displayResultContainer中。我已经用segue方法和parentViewController访问尝试了不同的选项,但仍然没有成功。
发布于 2014-07-07 09:43:34
有两种可能性。1.使用appDelegate。使用app委托中的属性在容器之间传递数据。把这个放在第一个容器里
MyAppdeleagte appDelegate=[[UIApplication sharedApplication]delegate];
appDelegate.dataToPass=dataToPass;在第二个容器中
MyAppdeleagte appDelegate=[[UIApplication sharedApplication]delegate];
dataToPass=appDelegate.dataToPass;2.使用ParentViewController。
在第一个容器中
ParentViewController parent=(ParentViewController *)[self parentViewController];
parent.dataToPass=dataToPass;在第二个容器中
ParentViewController parent=(ParentViewController *)[self parentViewController];
data=parent.dataToPass;发布于 2014-07-07 09:15:42
使用代表。
步骤:
发布于 2014-07-07 09:09:07
必须在第二个UIContainerView中声明此方法
UIContainerView2
-(id)initWithsetresult:(Int)Result {
int showPreResult = result;
return self;
}按钮动作:
antagonist = [[UIContainerView2 alloc]initWithsetresult: calculateResult];https://stackoverflow.com/questions/24606445
复制相似问题