无法填充 ViewController 类中的数据
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难说到底是什么问题。首先,您没有使用标准 TTNavigator。这不是必需的,但它更容易使用,特别是当您使用 320 个 TTViewController 时。
其次,AlbumController 必须在某处初始化(最好在应用程序启动的函数中):
我还建议将 AlbumController 对象放在 AppDelegate 中,而不是另一个 UIViewController 的一部分。这将使事情变得更加容易:
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):
I also recommend having the AlbumController object in the AppDelegate and not a part of another UIViewController. It will make things much easier: