- 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/
我正在 Apple Developer 网站上查看适用于 iOS 的 SimpleDrillDown 示例:http://developer.apple.com/library/ios/#sample
我是新手 我的xcode版本是11.2.1,swift是5.1.2 当我在MasterView中使用NavigationView时,我有两个DetailView 我想在第一个DetailView关闭时
I am newbie on python django. when following Django Tutorial > Part04 > Generic View , i have troubl
我是 Django 的新手。有一个 html 页面 (project_details) 应该显示项目的标题和任务,但只显示项目的标题,而不是任务。任务存在,问题出在过滤器上!!! View .py 错
我有一个要显示为详细信息 View 的模型,我创建了一个 ListView ,该 ListView 有一个指向其详细信息 View 的链接。我没有收到任何错误,但模板没有呈现任何模型细节 链接到 De
我有点困惑,并希望利用 DetailView 功能使用外键作为我的过滤器来显示数据。基本上我的模型是这样的: class Category(models.Model): name = mode
我的模型事件有一个基于类的 DetailView,我想显示通过外键关联的类别条目。 模型.py class Event(models.Model): name = models.CharFie
我想返回用户相关记录。有人可以帮助我吗? 我的部分观点 class UserProfileDetailView(DetailView): model = get_user_model()
我正在尝试使用聚光灯结果引导用户到我的应用程序中的相应部分。 MainView 有几个按钮,允许转到应用程序的不同区域,其中之一是电话目录,位于它自己的 SplitViewController 内。
我正在尝试创建主细节 View 应用程序,但有点卡住了。 我有一个包含 100 个 DynamicPrototype Cells 的 tableView 显示 Bars,当我点击一个 cell 时,我
在应用程序中,我有两个模型,名为“类(class)”和“步骤”。每个步骤都属于一个类(class),每个类(class)又包含许多步骤。但是,我在为步骤创建详细 View 时遇到问题。例如,当我转到
我有 2 个模型,我得到了 IndexView使用 get_context_data 正常工作方法。然而我的 DetailView使用相同的技术是行不通的。我如何简单地将 2 个模型放入 Detail
我正在寻找一种优雅的方式来显示 Django 中所有可用的项目(不仅仅是选中的项目)DetailView , 同时对选中的样式进行样式化。 给定以下模型: class Topping(models.M
有没有简单的方法可以强制DetailView在 Yii2 中忽略其 attributes 中的这些字段列表,特别是 model是空的? 或者唯一的方法是定义 attributes 上的每个属性具有自己
我正在尝试在 View 文件中渲染图像。我的代码如下: $model, 'attributes' => [ 'id', 'name',
我收到以下错误: ImproperlyConfigured at /elearning/7447932a-6044-498a-b902-97cbdd0a4001/ DetailView is miss
在我的 DetailView 中,我想根据我的 url 中的 kwargs 获取对象,另外还检索它的所有相关(外键)值。 我用: queryset = Category.objects.select_
我正在制作一个将 PO 导出为 PDF 的采购订单系统,但我需要在上半部分显示来自买方和卖方的数据。我想并排放置 2 个 DetailView,每个都有 50% 的页面宽度。有可能的?到目前为止,我还
在浏览了几个谷歌搜索结果页面后,我仍然陷入同样的问题。我正在尝试在博客文章下方实现评论字段。我感谢任何提示和建议! 我正在 Django 中开发一个博客,该博客设置了第一个通用 ListView
我需要在 Django 中编写一个 DetailView。我实现了这个功能。但是,我需要添加更多数据以及上下文对象。我将如何实现这一目标。 我的一般观点是: class AppDetailsView(
我是一名优秀的程序员,十分优秀!