注:組件化之后 發(fā)現(xiàn)原來的資源都無法正常的加載了 問題的原因就是路徑發(fā)生了改變 所以想正確的加載資源 必須把路徑修改正確
一.圖片資源路徑
以WKWebTest?
//stringName 就是你圖片資源的名字
- (UIImage*)setResourcesPath:(NSString*)stringName {
?? ?//------------------路徑
? ? NSURL *urlClassBundle = [[NSBundle bundleForClass:[self class]] URLForResource:@"WKWebTest" withExtension:@"bundle"];
? ? NSBundle*urlBundle = [NSBundlebundleWithURL:urlClassBundle];
? ? UIImage *image = [UIImage imageNamed:stringName inBundle:urlBundle compatibleWithTraitCollection:nil];
? ? returnimage;
}
二.storyboard路徑
- (UIViewController*)loadStoryboard:(UIViewController*)viewController {
?//獲取pods中的路徑
? ? NSBundle*currentBundle = [NSBundlebundleForClass:[viewControllerclass]];
? ? NSURL*bundleUrl = [currentBundleURLForResource:@"SXLoginCompont"withExtension:@"bundle"];
? ? NSBundle *dle = [NSBundle bundleWithURL:bundleUrl];
? ?//storyboardv創(chuàng)建
? ? UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"SXLogin" bundle:dle];
? ? return [mainStoryBoard instantiateViewControllerWithIdentifier:@"SXLoginViewController"];
}
三.xib路徑
? 下面簡易的寫了下 具體用法按照自己實際怎么用就怎么寫
? ? UINib *loadNib = [UINib nibWithNibName:@"SXLogin" bundle:dle];
? ? return [_tableView registerNib:loadNib forCellReuseIdentifier:@"這里寫cell的Identifierin"];