Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created April 22, 2012 09:17
Show Gist options
  • Save onevcat/2462909 to your computer and use it in GitHub Desktop.
Save onevcat/2462909 to your computer and use it in GitHub Desktop.
-(NSArray *)loadPadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options {
NSString *newName = [name stringByReplacingOccurrencesOfString:@"@pad" withString:@""];
newName = [newName stringByAppendingFormat:@"@pad"];
//判断是否存在
NSFileManager *fm = [NSFileManager defaultManager];
NSString* filepath = [[NSBundle mainBundle] pathForResource:newName ofType:@"nib"];
//这里调用的loadPadNibNamed:owner:options:实际为为交换后的方法,即loadNibNamed:owner:options:
if ([fm fileExistsAtPath:filepath]) {
return [self loadPadNibNamed:newName owner:owner options:options];
} else {
return [self loadPadNibNamed:name owner:owner options:options];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment