我有什么接缝很简单,但我无法让它工作。 我有一个变量进入ViewController(由模态视图呈现),并在viewController中访问appDelelgate以获取传递NSArray中的变量。我可以在我分配它之前确认变量是否可用于我的NSLog,所以我知道它在那里。 .h文件中的 是以下内容;从视图中的Array中的appDelegate变量分配IBOutlet控制器
@class ViolinMakerAppDelegate;
@interface DetailsViewController : UIViewController
{
ViolinMakerAppDelegate *dappDelegate;
DetailsViewController *detailsView;
IBOutlet UIViewController *modalViewController;
IBOutlet UITextView *violinMakerDescription;
}
@property (retain, nonatomic) ViolinMakerAppDelegate *dappDelegate;
@property (nonatomic, retain) DetailsViewController *detailsView;
@property(nonatomic, assign) UIViewController *modalViewController;
@property (nonatomic, retain) IBOutlet UITextView *violinMakerDescription;
在.m文件中有以下内容。
#import "DetailsViewController.h"
#import "ViolinMakerAppDelegate.h"
@implementation DetailsViewController
@synthesize detailsView, violinMakerDescription, dappDelegate;
- (void)viewWillAppear:(BOOL)animated
{
dappDelegate = (ViolinMakerAppDelegate *) [[UIApplication sharedApplication] delegate];
DetailsViewController *detailsViewController = [[DetailsViewController alloc]initWithNibName:@"DetailsViewController" bundle:nil];
self.detailsView = detailsViewController;
// Tried below, but the variable is not getting to the IBOutlet..
NSString *aviolinMakerDescription = [dappDelegate.violinMakers description];
[self.detailsView.violinMakerDescription setText:aviolinMakerDescription];
NSLog(@"violinMakerDescription: %@", [dappDelegate.violinMakers description]);
// tried -----> [self.detailsView.violinMakerDescription setText:[dappDelegate.violinMakers description]];
}
我相信这很简单,因为我知道变量'description'具有我想要的内容。我只是一直得不到IB的静态文本。我确定我的IB连接正确,因为我的工作方式与RootViewController推送另一个视图类似,并且所有连接都相同且非常简单。一个IB出口,一个UITextView。
对我来说这听起来很疯狂,但是有没有任何理由,因为这个视图是一个模态视图,它不能将变量加载到文本字段中,只能从模态控制器发回变量到程序中?
任何人在那里喜欢帮助我通过我的密集头骨得到这个我失踪了这个最终代码将它分配给IBOutlet? 在此先感谢, 柯克
@Scott 我已经尝试了一切,并认为这是所需要的......不知道真的。 这里是我以模式方式呈现DetailsViewController,从另一个视图,由根控制器推送。
case 0:
{
DetailsViewController *detailsViewController = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil];
UINavigationController *aDetailsViewController = [[UINavigationController alloc] initWithRootViewController:detailsViewController];
self.detailsView = detailsViewController;
// °°°[self.view addSubview:detailsViewController.view];
// self.violinMakerView = violinMakerViewController;
// [[self navigationController] pushViewController:detailsViewController animated:YES];
dappDelegate = (ViolinMakerAppDelegate *) [[UIApplication sharedApplication] delegate];
// This does show the variable is loaded here too.
NSLog(@"violinMakerDescription from Details Segment: %@", [dappDelegate.violinMakers description]);
// attempting to load it here as well rem out doesn't change things
[violinMakerDescription setText:[dappDelegate.violinMakers description]];
// NSLog(@"violinMakerDescription loaded in segment Segment: %@", violinMakerDescription);
[self presentModalViewController:aDetailsViewController animated:YES];
[violinMakerView release];
[detailsViewController release];
[aDetailsViewController release];
break;
我真的不要知道我需要在DetailsViewController在上面的文字得到它加载变量....我希望这对你有意义。感谢您提供任何帮助或帮助的信息!
我想你到那里的东西,但我在细节视图控制器中分配变量,所以不应该是为视图启动的那个?我如何知道视图的启动位置?它在页面的模式视图启动中向我展示,它会加载我将该变量分配给的相同视图。我试图给这个变量分配相同的原因,但是我感觉Interface Builder是问题所在,或者你说我没有看到生成的视图... – Digiguy 2009-12-04 21:16:03