내 세부 정보보기에서로드 할 데이터를 가져 오려고합니다. 어느 누구도 한번 들여다보고 왜 그것이 보이지 않는지 볼 수 있습니까? 상세 뷰가 아닌 내 rootviewcontroller에서 제대로로드됩니다.데이터가 상세 정보로로드되지 않습니다.
DetailViewController.m
#import "DetailViewController.h"
@implementation DetailViewController
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)setIcon:(UIImage *)newIcon
{
[super setIcon:newIcon];
iconView.image = newIcon;
}
- (void)setPublisher:(NSString *)newPublisher
{
[super setPublisher:newPublisher];
publisherLabel.text = newPublisher;
}
- (void)setName:(NSString *)newName
{
[super setName:newName];
nameLabel.text = newName;
}
- (void)dealloc
{
[iconView release];
[publisherLabel release];
[nameLabel release];
[priceLabel release];
[super dealloc];
}
@end
는 detailviewcontroller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface DetailViewController : UIViewController {
IBOutlet UIImageView *iconView;
IBOutlet UILabel *publisherLabel;
IBOutlet UILabel *nameLabel;
IBOutlet UILabel *priceLabel;
}
@end
RootViewControllerPoints.m
#import "RootViewControllerPoints.h"
#import "DetailViewController.h"
#define USE_INDIVIDUAL_SUBVIEWS_CELL 1
#define DARK_BACKGROUND [UIColor colorWithRed:151.0/255.0 green:152.0/255.0 blue:155.0/255.0 alpha:1.0]
#define LIGHT_BACKGROUND [UIColor colorWithRed:172.0/255.0 green:173.0/255.0 blue:175.0/255.0 alpha:1.0]
@implementation RootViewController
@synthesize tmpCell, data;
#pragma mark View controller methods
- (void)viewDidLoad
{
[super viewDidLoad];
// Configure the table view.
self.tableView.rowHeight = 73.0;
self.tableView.backgroundColor = DARK_BACKGROUND;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
// Load the data.
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
self.data = [NSArray arrayWithContentsOfFile:dataPath];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
return YES;
default:
return NO;
}
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ApplicationCell";
ApplicationCell *cell = (ApplicationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
#if USE_INDIVIDUAL_SUBVIEWS_CELL
[[NSBundle mainBundle] loadNibNamed:@"IndividualSubviewsBasedApplicationCell" owner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
#endif
}
// Display dark and light background in alternate rows -- see tableView:willDisplayCell:forRowAtIndexPath:.
cell.useDarkBackground = (indexPath.row % 2 == 0);
// Configure the data for the cell.
NSDictionary *dataItem = [data objectAtIndex:indexPath.row];
cell.icon = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]];
cell.publisher = [dataItem objectForKey:@"Publisher"];
cell.name = [dataItem objectForKey:@"Name"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
detailViewController. = [data objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
@end
이 아주 잠시 동안 저를 도청하고있다, 나는 많은 검토 한 예제, 자습서 및 심지어 다른 아이폰 devs 물었다. 모든 소스가 다른 것을 말하는 것 같습니다.
아이폰을 태그로 추가하십시오. 그러면 더 많은 답변을 얻을 수 있습니다. – Emil
"detailViewController. = [data objectAtIndex : indexPath.row]"란 무엇입니까? didSelectRowAtIndexPath에서해야 할 일은 무엇입니까? 그것이 실제 코드입니까, 아니면 오타가 있습니까? 왜 detailViewController 뒤에 점이 있습니까? – DyingCactus
아, 다른 사용자가 제안한 코드 라인이었습니다. 디버거가 입력 한 것처럼 오류가 발생합니다. 데이터를 모두 삭제해도 데이터는 하위 뷰로 전달되지 않지만 모두로드됩니다. – user278342