【发布时间】:2013-01-29 19:03:33
【问题描述】:
我有一个 UIViewController 使用定义的 loadView 方法调用另一个视图控制器。我尝试了很多方法都没有成功解决 loadView 方法没有被调用的问题。
感谢任何帮助。
谢谢。 马科斯
调用者 UIViewController
#import "MyAlbumViewController.h"
@interface ViewController : UIViewController
@end
实现
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated{
UIViewController*albumVC = [[MyAlbumViewController alloc] init];
[self.navigationController pushViewController:albumVC animated:YES];
}
@end
调用 UIViewController
@interface MyAlbumViewController : NIToolbarPhotoViewController <NIPhotoAlbumScrollViewDataSource>
@end
实施
#import "MyAlbumViewController.h"
@implementation MyAlbumViewController
- (void)loadView{
[super loadView];
self.photoAlbumView.dataSource = self;
// Set the default loading image.
self.photoAlbumView.loadingImage = [UIImage imageWithContentsOfFile:
NIPathForBundleResource(nil, @"NimbusPhotos.bundle/gfx/default.png")];
self.title = NSLocalizedString(@"Loading...", @"Navigation bar title - Loading a photo album");
[self loadAlbumInformation];
}...
【问题讨论】:
-
你为什么使用 loadView 而不是 viewDidLoad?
-
这是来自 Nimbus iOS 框架的编程视图。
-
查看stackoverflow.com/questions/7788928/… 了解有关 loadView 的讨论
-
是的,如果您使用的是编程视图,那么使用 loadView 非常好。我想可能是你的 self.navigationController = nil
标签: ios objective-c nimbus-ios