我有一个用定义的loadView方法调用另一个视图控制器的UIViewController。我已经尝试了许多方法来解决loadView方法未被调用的问题,但都没有成功。
任何帮助都是非常感谢的。
谢谢。MArcos
调用者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];
}...发布于 2013-01-30 03:16:28
loadView的思想是完全覆盖该方法,而不是调用super
您所做的正是viewDidLoad方法的用途,无论您是从nib文件还是其他文件加载它
我引用你自己的帖子,在你的ViewController.m中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}发布于 2013-01-30 03:39:43
我使用以下命令来推送视图控制器:
[self.navigationController pushViewController:albumVC animated:YES];我刚刚更改为:
[self presentViewController:albumVC animated:YES completion:nil];UIViewController导航控制器
navigationController视图控制器层次结构中最接近的祖先,即导航控制器。(只读)
@ property (非原子,只读,保留) UINavigationController *navigationController讨论如果接收方或其祖先之一是导航控制器的子级,则此属性包含拥有导航控制器。如果视图控制器未嵌入导航控制器中,则此属性为nil。
https://stackoverflow.com/questions/14590304
复制相似问题