- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用可以完美地导航 View 。现在,由于某种我无法弄清楚的原因,我的 detailView 没有在我的模态视图中的 pushViewController:detail
方法中呈现。
我不明白为什么它不再工作了。任何帮助,将不胜感激。谢谢。
方法如下:
- (void)tableView:(UITableView *)tView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 1){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 2){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 3){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 4){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
}
这是类(class)代码。我不确定是否需要使用 modalView 传入 navigationController:
//
// ModalView.m
// DiningLog
//
// Created by Eric Rea on 10/10/11.
// Copyright 2011 Avid. All rights reserved.
//
#import "ModalView.h"
#import "DetailView.h"
@implementation ModalView
@synthesize tableView, excersizeName, numSets, time, restTime, dateFormatter, rating, excersizeArray, plistArray, numberWithBool;
-(IBAction) cancel:(id)sender{
[self dismissModalViewControllerAnimated:YES];
}
-(IBAction) save:(id)sender{
// get paths from root direcory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"ExcersizeList.plist"];
// check to see if Data.plist exists in documents
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
{
// if not in documents, get property list from main bundle
plistPath = [[NSBundle mainBundle] pathForResource:@"Excersizes" ofType:@"plist"];
}
// read property list into memory as an NSData object
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
// convert static property list into dictionary object
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
if (!temp)
{
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
}
// assign values
self.plistArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];
NSLog(@"The contents of plistArray is%@", plistArray);
// set the variables to the values in the text fields
self.excersizeArray = [[NSMutableArray alloc] initWithCapacity:4];
[excersizeArray addObject:excersizeName];
[excersizeArray addObject:numSets];
[excersizeArray addObject:time];
[excersizeArray addObject:restTime];
[plistArray addObject:excersizeArray];
// create dictionary with values in UITextFields
NSDictionary *plistDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: plistArray, nil] forKeys:[NSArray arrayWithObjects: @"Excersizes", nil]];
NSString *error = nil;
// create NSData from dictionary
// NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
// check is plistData exists
if(plistDict)
{
// write plistData to our Data.plist file
[plistDict writeToFile:plistPath atomically:YES];
}
else
{
NSLog(@"Error in saveData: %@", error);
[error release];
}
[self dismissModalViewControllerAnimated:YES];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tView {
// Return the number of sections.
return 1;
}
-(void)setObject:(id)object forNum:(int)num{
if(num == 0){
self.excersizeName = object;
NSLog(@"res %@", self.excersizeName);
}else if(num == 1){
self.numSets = object;
NSLog(@"res %@", self.numSets);
}else if(num == 2){
self.time = object;
NSLog(@"res %@", self.time);
}else if(num == 3){
self.restTime = object;
NSLog(@"res %@", self.restTime);
}else if(num == 4){
self.rating = [object floatValue];
}
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 5;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
if(indexPath.row == 0){
cell.textLabel.text = @"Excersize";
cell.detailTextLabel.text = excersizeName;
}
if(indexPath.row == 1){
cell.textLabel.text = @"Sets";
cell.detailTextLabel.text = numSets;
}
if(indexPath.row == 2){
cell.textLabel.text = @"Time";
cell.detailTextLabel.text = time;
}
if(indexPath.row == 3){
cell.textLabel.text = @"Rest";
cell.detailTextLabel.text = restTime;
}
if(indexPath.row == 4){
cell.textLabel.text = @"Rating";
cell.detailTextLabel.text = [NSString stringWithFormat:@"%f",rating];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (NSDateFormatter *)dateFormatter {
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
}
return dateFormatter;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 1){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 2){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 3){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
if(indexPath.row == 4){
NSLog(@"hey");
DetailView * detail = [[DetailView alloc] initWithNumber:indexPath.row];
detail.delegate = self;
[[self navigationController] pushViewController:detail animated:YES];
}
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
最佳答案
您是否调试并检查过您的 navigationController
不是 nil ?
关于objective-c - pushViewController:detail 不推送 detailView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7907282/
我想为我的 View 设置动画以响应用户操作,使其看起来像 pushviewcontroller 的动画。也就是说,我希望 View 响应用户操作从屏幕向左滑动。但是,我不想创建一个新 View 并使
如何从 tabBarController 和 navigationController 切换到新 View ,并且新 View 中没有 tabBar 和 navigationBar?我需要向右滑动才能
这是我第一次尝试使用 UINavigationController 实现从一个 tableView 单元格到另一个 tableView 的导航,它对我不起作用。我没有使用 nib 文件,我有一个简单的
推送到堆栈上的 View Controller 不能是选项卡栏 Controller 的实例,并且它不能已经在导航堆栈上。 我想知道我如何发现我即将插入堆栈的 View Controller 是否已经
我想做的是从左侧插入ViewController的自定义动画。我已经创建了自定义过渡委托(delegate),并提供了自定义动画,一切正常(新 View 从左侧幻灯片)。唯一的问题是 iOS 中的推送
我有一个 SidebarMenueController,它是启动应用程序后的入口点。在其中我有一个嵌入侧边栏(滑出)菜单的导航 Controller 。使用 sideBarDidSelectButto
viewcontroller 上有一个按钮,当我单击 按钮 pushviewcontroller 不起作用。 我的 appdelegate.m 文件: - (BOOL)applicationUIApp
我想知道是否可以在没有标签栏和导航栏的情况下全屏推送 NavigationController 的 ViewController。我的问题如下: 我的应用在 TabBarController 中嵌入了
我使用此代码来呈现 UIviewController: -(IBAction)openWoodenPage3:(id)sender{ UIStoryboard *storyboard = [UISto
这是我在网上获得的代码,它确实适用于我之前开发的项目。但是在这个项目中,当我 NSLog 它时,self.navigationController 为 null ,网上的人讨论过在委托(delegat
我正在尝试完成一些非常简单的事情。当我的 Collection View 中的唯一项目被推送时,我试图以编程方式推送到 viewController。什么都没发生。我相信在我纠结的一团糟中有不止一个问
我有一个导航 Controller 、一个 View Controller 和一个 TableView ,它们都是在我的 Storyboard中创建的: 当您触摸 TableView 中的某一行时,它
在 iPhone 应用程序中,我希望在根导航 Controller 的导航栏右侧有一个导航按钮。但是,每次我将另一个 viewController 推到导航 Controller 顶部并且右侧插槽变空
我在 appDelegate 中设置了 navigationController,但现在我在另一个 ViewController 中记忆起它,但它不起作用。这是我的代码: 在appDelegate.h
我有三个 View Controller 。 MainViewController、secondViewController、thirdViewController。我想知道一旦我点击 thirdVi
我对 Objective-C 和 iPhone 编程还很陌生,所以如果这是一个新手问题,我深表歉意。我有一个简单的应用程序,需要从一个 View 转到另一个 View 。第一个 View 是 UIVi
我正在做基于 View 的应用程序,我已经添加了表格 View 。现在我已经在 didSelectRowAtIndexPath 方法中编写如下,当用户点击一行然后导航到“learncourse”nib
我正在尝试推送 ViewController,但我的应用程序每次都会崩溃。 我正在使用 UIImagePickerControllerDelegate 拍照,一旦拍照,这段代码就会运行: func i
我在一个按钮中做了一个推送功能: @IBAction func prodButton(sender: AnyObject) { let storyboard = UIStoryboard(na
我是 IOS 的新手。我所做的只是简单地在我的主视图上放置一个 UIButton,我希望当我单击该按钮时它应该将我带到下一个堆栈。为此,我正在做的是 -(IBAction)stack:(id)send
我是一名优秀的程序员,十分优秀!