Iphone Xcode IOS高级链接UITableView

Iphone Xcode IOS高级链接UITableView,iphone,objective-c,ios,xcode,uitableview,Iphone,Objective C,Ios,Xcode,Uitableview,我在Xcode中开发了一个选项卡式应用程序。我遇到了麻烦 我对我的进度很满意,但在pic2或scene2或SelectedCellViewController.m中,我不想看到下面Pic1或Scene1中的所有表格单元格。我只想看到一个表格单元和相关表格单元链接到Pic 3或场景3 你可以在Pic 1或Scene 1中选择一个表格单元格,然后你可以看到你选择的颜色的Pic,我将在图片下方包含一些信息。现在,您可以看到在pic2或场景2中,图片下方有多个表格单元格。我只想显示相关的表格单元格,这样

我在Xcode中开发了一个选项卡式应用程序。我遇到了麻烦

我对我的进度很满意,但在pic2或scene2或SelectedCellViewController.m中,我不想看到下面Pic1或Scene1中的所有表格单元格。我只想看到一个表格单元和相关表格单元链接到Pic 3或场景3

你可以在Pic 1或Scene 1中选择一个表格单元格,然后你可以看到你选择的颜色的Pic,我将在图片下方包含一些信息。现在,您可以看到在pic2或场景2中,图片下方有多个表格单元格。我只想显示相关的表格单元格,这样你就可以看到一个更大的版本,我已经对功能进行了编码,但是我不知道如何去掉pic2或场景2中的其余单元格

我不知道该怎么做,任何帮助都将不胜感激

选择CellViewController.h

@interface SelectedCellViewController : UIViewController {
NSString *labelText;
UIImage *banner;
IBOutlet UILabel *label;
IBOutlet UIImageView *imageView;
IBOutlet UITableView *sampleViewDecors;
UINavigationController *navigationController;
NSArray *sitesArray;
NSArray *bannerImages;
}

@property (nonatomic, copy) NSString *labelText;
@property (nonatomic, retain) UIImage *banner;
@property (nonatomic, retain) UITableView *sampleViewDecors;
@property (nonatomic, retain) NSArray *sitesArray;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) NSArray *bannerImages;

@end
视图控制器toshow.m

#import "SelectedCellViewController.h"
#import "DetailViewController.h"

@interface SelectedCellViewController ()

@end

@implementation SelectedCellViewController

@synthesize labelText;
@synthesize banner;
@synthesize sampleViewDecors;
@synthesize sitesArray;
@synthesize bannerImages;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
}
return self;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

#pragma mark - View lifecycle

- (void)viewDidLoad {


[super viewDidLoad];
[label setText:self.labelText];
[imageView setImage:self.banner];

// Load up the sitesArray with a dummy array : sites
NSArray *sites = [[NSArray alloc] initWithObjects:@"Click here for a bigger view", @"b", @"c", @"d", @"e", @"f", @"g", @"h", nil];
self.sitesArray = sites;
//[sites release];

/* Create the dummy banner images array and fill the main bannerImages array */

// Create the UIImage's from the images folder
UIImage *app = [UIImage imageNamed:@"french.png"];
UIImage *creat = [UIImage imageNamed:@"Creattica.jpg"];
UIImage *free = [UIImage imageNamed:@"Freelance.jpg"];
UIImage *net = [UIImage imageNamed:@"Netsetter.jpg"];
UIImage *rock = [UIImage imageNamed:@"Rockable.jpg"];
UIImage *tuts = [UIImage imageNamed:@"Tutsplus.jpg"];
UIImage *work = [UIImage imageNamed:@"Workawesome.jpg"];

/* Create the dummy array and fill with the UIImages. */
NSArray *banners = [[NSArray alloc] initWithObjects:app, creat, free, net, rock, tuts, work, nil];

// Set the main images array equal to the dummy array
self.bannerImages = banners;





[super viewDidLoad];
}

#pragma mark - Table View datasource methods

// Required Methods

// Return the number of rows in a section
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
return [sitesArray count];
}

// Returns cell to render for each row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CellIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

// Configure cell

NSUInteger row = [indexPath row];

// Sets the text for the cell
cell.textLabel.text = [sitesArray objectAtIndex:row];

// Sets the imageview for the cell
//cell.imageView.image = [imagesArray objectAtIndex:row];

// Sets the accessory for the cell
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

// Sets the detailtext for the cell (subtitle)
//cell.detailTextLabel.text = [NSString stringWithFormat:@"This is row: %i", row + 1];

return cell;
}

// Optional

// Returns the number of section in a table view
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

#pragma mark -
#pragma mark Table View delegate methods

// Return the height for each cell
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 78;
}

// Sets the title for header in the tableview
//-(NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
//  return @"Decors";
//}

// Sets the title for footer
//-(NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
//  return @"Decors";
//}

// Sets the indentation for rows
-(NSInteger) tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
return 0;
}


// Method that gets called from the "Done" button (From the @selector in the line - [viewControllerToShow.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView)] autorelease]];)
- (void)dismissView {
[self dismissViewControllerAnimated:YES completion:NULL];
}

// This method is run when the user taps the row in the tableview
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];

DetailViewController *detailviewControllerToShow = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
//[viewControllerToShow setLabelText:[NSString stringWithFormat:@"You selected cell: %d - %@", indexPath.row, [sitesArray objectAtIndex:indexPath.row]]];
detailviewControllerToShow.banner = [bannerImages objectAtIndex:indexPath.row];

[detailviewControllerToShow setModalPresentationStyle:UIModalPresentationFormSheet];
[detailviewControllerToShow setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[detailviewControllerToShow.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView)]];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailviewControllerToShow];
detailviewControllerToShow = nil;

[self presentViewController:navController animated:YES completion:NULL];
navController = nil;

//  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tapped row!"
//                                            message:[NSString stringWithFormat:@"You tapped: %@", [sitesArray objectAtIndex:indexPath.row]]
//                                            delegate:nil
//                                            cancelButtonTitle:@"Yes, I did!"
//                                            otherButtonTitles:nil];
//  [alert show];
//  [alert release];

self.labelText = nil;
self.banner = nil;
//[label release];
// [imageView release];
[super viewDidUnload];


}

- (void)viewDidUnload {



}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

您的tableView的行数与
站点中的值的行数相同。如果只有一个值,或者如果您更改了节中的行数,您将得到一个包含一行的表

// Return the number of rows in a section
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
    return 1;
}

如何更改//返回节中的行数-(NSInteger)tableView:(UITableView*)table numberOfRowsInSection:(NSInteger)节{返回1;在Pic2或场景2中只能显示相关的表格单元格。在场景2中,我需要显示相关的表格单元格。例如,如果你点击彩色梅花树,你会进入第二个场景,在那里你会看到一个样本和一些信息,我想在场景2中只能显示梅花树的表格单元格,这样当你点击进入场景3时,一个更大的版本。我认为您是对的,我需要更改为“行数”以仅显示相关数组。}