我有什麼接縫很簡單,但我無法讓它工作。 我有一個變量進入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