无法填充 ViewController 类中的数据

发布于 2024-11-18 20:24:10 字数 1547 浏览 1 评论 0原文

我正在使用 Three20 制作一个画廊,我的问题是当我尝试创建视图以显示画廊时,我的 AlbumController 中没有填充从以前的视图中获取的照片。 照片位于 NSArray (inputAlbumController) 中,下一个视图的标题位于 NSTextField (txtSearch) 中,应用程序输入 if 语句 (self.albumView == nil),我使用 NSLog 测试了它们,但是当我尝试在下一个视图中通过设置器传输它们,但我什么也没得到。以下是解决此问题所需的一些代码:

这是 rootViewController.h:

@interface rootViewController : UIViewController {
    AlbumController *albumView;
    IBOutlet UITextField *txtSearch;
}
@property (nonatomic, retain) AlbumController *albumView;

这是我的 rootViewController.m 中的函数:

geoFlickrAppDelegate *appDelegate = (geoFlickrAppDelegate *)[[UIApplication sharedApplication] delegate];
if(self.albumView == nil) {
    [albumView setMyImages:inputAlbumController];
    [albumView setMyTitle:txtSearch.text];
    //self.albumView = album;
    [appDelegate toGallery];
}

[self.navigationController pushViewController:self.albumView animated:YES];

这​​是我的 AlbumController.h:

@interface AlbumController : TTThumbsViewController {
    NSArray *myImages;
    NSString *myTitle;
}
@property (nonatomic, retain) NSArray *myImages;
@property (nonatomic, retain) NSString *myTitle;

这是我的 AlbumController.m 中的 ViewDidLoad:

- (void)viewDidLoad { 
self.photoSource = [[PhotoSource alloc]  
                    initWithType:PhotoSourceNormal  
                    title:myTitle  
                    photos:myImages  
                    photos2:nil  
                    ];  
} 

知道为什么吗这样吗? 我错过了什么吗?

I am making a gallery using the Three20, my problem is when I try to create my view to show the gallery my AlbumController isn't populated with the photos get from my previous view.
The Photos are there in a NSArray (inputAlbumController) and my title for the next view is in the NSTextField (txtSearch), the application enters the if-statement (self.albumView == nil), I tested them out with NSLog, but when I try to transfer them via the setters on the next view I get nothing. Here is some of the code needed for this problem:

This is the rootViewController.h:

@interface rootViewController : UIViewController {
    AlbumController *albumView;
    IBOutlet UITextField *txtSearch;
}
@property (nonatomic, retain) AlbumController *albumView;

This is in the function from my rootViewController.m:

geoFlickrAppDelegate *appDelegate = (geoFlickrAppDelegate *)[[UIApplication sharedApplication] delegate];
if(self.albumView == nil) {
    [albumView setMyImages:inputAlbumController];
    [albumView setMyTitle:txtSearch.text];
    //self.albumView = album;
    [appDelegate toGallery];
}

[self.navigationController pushViewController:self.albumView animated:YES];

This is my AlbumController.h:

@interface AlbumController : TTThumbsViewController {
    NSArray *myImages;
    NSString *myTitle;
}
@property (nonatomic, retain) NSArray *myImages;
@property (nonatomic, retain) NSString *myTitle;

This is the ViewDidLoad from my AlbumController.m:

- (void)viewDidLoad { 
self.photoSource = [[PhotoSource alloc]  
                    initWithType:PhotoSourceNormal  
                    title:myTitle  
                    photos:myImages  
                    photos2:nil  
                    ];  
} 

Any idea why is this so?
Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流心雨 2024-11-25 20:24:10

很难说到底是什么问题。首先,您没有使用标准 TTNavigator。这不是必需的,但它更容易使用,特别是当您使用 320 个 TTViewController 时。

其次,AlbumController 必须在某处初始化(最好在应用程序启动的函数中):

AlbumController* _albumContoller = [[AlbumController alloc] init];

我还建议将 AlbumController 对象放在 AppDelegate 中,而不是另一个 UIViewController 的一部分。这将使事情变得更加容易:

[appDelegate.albumView setMyImages:inputAlbumController];
[self.navigationController pushViewController:appDelegate.albumView animated:YES];

It's hard to tell what's exactly the issue. For starters, you're not using the standard TTNavigator. It's not required, but it's easier to work with, especially when you use three20 TTViewControllers.

Secondly, AlbumController has to be initialized somewhere (preferable in the app launched function):

AlbumController* _albumContoller = [[AlbumController alloc] init];

I also recommend having the AlbumController object in the AppDelegate and not a part of another UIViewController. It will make things much easier:

[appDelegate.albumView setMyImages:inputAlbumController];
[self.navigationController pushViewController:appDelegate.albumView animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文