我相信一个UIViewController子类可以提供你所需要的一切。您只需提供支持每种不同类型图片所需的差异。让我们假定这些差异都只是图片的它显示了描述和类型:
MyViewController.h:
@MyViewController : UIViewController
@property (strong, nonatomic) NSString *description;
@property (strong, nomatomic) NSString *type;
// Designated initializer
- (id)initWithNibName:(NSString *)nibName
bundle:(NSBundle *)nibBundle
description:(NSString *)description
type:(NSString *)type;
@end
MyViewController。L:
@implementation MyViewController
- (id)initWithNibName:(NSString *)nibName
bundle:(NSBundle *)nibBundle
description:(NSString *)description
type:(NSString *)type
{
self = [super initWithNibName:nibName bundle:nibBundle];
if (self != nil)
{
self.description = description;
self.type = type;
}
return self;
}
- (NSArray *)fetchPics
{
NSMutableArray *pics = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.somewhere.com/fetchPics?type=%@", self.type]];
...
return pics;
}
@end
它应该再仅仅是创建等。无论需要的视图控制器的情况下:
MyViewController *catVC = [[MyViewController alloc] initWithNibNamed:@"Something" bundle:nil description:@"Cats" type:@"cat"];
...
请说明“以及提取数据的方法的参数”。这些差异是什么? – trojanfoe 2013-03-01 14:52:49