我相信一個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