Я много искал об этой теме, и я не могу получить этот код. Когда я его выполняю, он показывает только мой тест NSLog, но код, который следует переходить с одного взгляда на другой, ничего не делает. Здесь у вас есть следующий код:Перейдите из ячейки UITableView в подробный вид
//FirstViewController.h
#import <UIKit/UIKit.h>
#import "StationDetailsViewController.h"
@interface FirstViewController : UIViewController{
NSArray *ListaEstaciones;
NSArray *ListaID;
}
@property (nonatomic, retain) NSArray *ListaEstaciones;
@property (nonatomic, retain) NSArray *ListaID;
@end
//FirstViewController.m
#import "FirstViewController.h"
#import "StationDetailsViewController.h"
@implementation FirstViewController
@synthesize ListaEstaciones;
@synthesize ListaID;
//...
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"Pushing...");
StationDetailsViewController *controller = [[StationDetailsViewController alloc] initWithNibName:@"StationDetailsViewController" bundle:nil];
[[self navigationController] pushViewController:controller animated:YES];
[controller release], controller = nil;
}
@end
Я пробовал много учебники и мою книгу, но я не знаю, что не так. Большое спасибо, ребята.
EDIT: прочитав ответы, я обнаружил, что ошибка находится на AppDelegate.m, где определен rootViewController.
//AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UIViewController *viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Я не знаю, что изменить здесь, чтобы сделать это: [[само navigationController] pushViewController: контроллер анимации: YES]; исправно работает.
у вас, вероятно, нет self.navigationController. У вас есть контроллер навигации как rootViewController? Начните с шаблона на основе навигации –
Мое приложение - TabBarController, первая вкладка которого является видом, который я скопировал здесь. В AppDelegate.m у меня есть это: self.window.rootViewController = self.tabBarController; –