提供不切换到详图时,连接到签栏控制器
-
27-09-2019 - |
题
我已经创建了一个选项栏的应用,取默认的属性和SecondView和加入以下两个ViewControllers:
- JustAnotherView(这是一个简单的UIViewController带)内的)
- MyListOfItems(这是一个UIViewController与提供内部)
我有一个第3ViewController称为ListOfItemsDetailViewController带)内应该是所谓的时的用户接触的一个提供细胞。
该应用程序的汇编没有问题。我可以触摸的两个选项栏按钮和正确的出现。
问题:当我点提供一个细胞,代码转换到的详细地图被执行(没有崩溃或错误),但是从来没有显示。
这里是截图应用程序和调试用一只显示了它过去的pushViewController没有崩溃:
http://clip2net.com/clip/m52549/thumb640/1281588813-9c0ba-161kb.jpg
这里是代码。
MyListOfItemsViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "ListOfItemsDetailViewController.h";
@interface MyListOfItemsViewController : UIViewController {
ListOfItemsDetailViewController *listOfItemsDetailViewController;
}
@property (nonatomic, retain) ListOfItemsDetailViewController *listOfItemsDetailViewController;
@end
这里是MyListOfItemsViewController.m文件:
#import "MyListOfItemsViewController.h"
@implementation MyListOfItemsViewController
@synthesize listOfItemsDetailViewController;
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.title = @"My List Of Items";
NSLog(@"My List Of Items Did Load");
}
#pragma mark -
#pragma mark Table view data source
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
NSString *cellMessage;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cellMessage = [NSString stringWithFormat:@"indexPath: %d",indexPath.row];
cell.textLabel.text = cellMessage;
return cell;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ListOfItemsDetailViewController *vcListOfItemsDetail = [[ListOfItemsDetailViewController alloc]
initWithNibName:@"ListOfItemsDetail" bundle:[NSBundle mainBundle]];
self.listOfItemsDetailViewController = vcListOfItemsDetail;
[vcListOfItemsDetail release];
[self.navigationController pushViewController:self.listOfItemsDetailViewController animated:YES];
NSLog(@"Did Execute didSelectRowAtIndexPath WITHOUT Crashing or Error.");
}
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
NSLog(@"My List Of Items View Did Unload");
}
- (void)dealloc {
[super dealloc];
}
@end
请帮助。它将非常感谢!!!
我已经驾驶自己的疯狂试图获得基本的导航下在iOS平台。
此外,赦免的外行人的问题,我知道你们中的大多数已经了解如何做到这一点。
在此先感谢。Jaosn
解决方案
在 tableView:didSelectRowAtIndexPath:
你是引用navigationController通过 self.navigationController
,这可能并不存在。你必须使用一个UINavigationController作为一个图控制你tabView和rootViewController的,navigationController应MyListOfItemsViewController.
请注意,你需要一个UINavigationController于你的详细地图,推进和自我。navigationController是唯一的方式检索的一个,已创建并插入层次结构之前。
其他提示
而不是第2个标签的viewcontroller是一个tableviewcontroller,使它成为一个UINavigationController和设置navcontroller的RootViewController为"MyListOfItems".一旦你这么做,你将有机会获得navigationController酒店在你viewcontroller和可以使用推动和流行。
或如果你不想要做到这一点,唯一的途径就是动画之间的意见通过程序(即删除一个图和添加其他一个或加入的其他查看上顶的前景)