2012-01-16 3 views
0

のための新たな詳細ビューをプッシュすることは....私が欲しいものを車両各オブジェクト

のリストとテーブルビューを持っていることは、それらのそれぞれを説明するテキスト/段落でビューをプッシュするそれらの各車両です助けてください車両。私はコーディングに新しいです、これはこれはこれはdetailview.h

ある

#import "table 1.h" 
#import "detailview.h" 

@implementation table_1 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (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. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    vehicle = [[NSMutableArray alloc] init]; 

    [vehicle addObject:@"sedan"]; 
    [vehicle addObject:@"van"]; 
    [vehicle addObject:@"suv"]; 
    [vehicle addObject:@"truck"]; 

    // Uncomment the following line to preserve selection between presentations. 
    // self.clearsSelectionOnViewWillAppear = NO; 

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    // Configure the cell... 
    cell.textLabel.text = [vehicle objectAtIndex:indexPath.row]; 

    return cell; 
} 
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath { 

    //return UITableViewCellAccessoryDetailDisclosureButton; 
    return UITableViewCellAccessoryDisclosureIndicator; 
} 


#pragma mark - Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSString *selectedcar = [vehicle objectAtIndex:indexPath.row]; 

    detailview *dvController = [[detailview alloc] initWithNibName:@"detailview" bundle:[NSBundle mainBundle]]; 
    dvController.selectedVehicle = selectedcar; 
    [self.navigationController pushViewController:dvController animated:YES]; 

    dvController = nil; 
} 

@end 

私table.mある

#import <UIKit/UIKit.h> 

@interface table_1 : UITableViewController 
{ 
    NSMutableArray *vehicle; 
} 

@end 

私table.hある

簡単な回答を保つようにしてみてください

#import <UIKit/UIKit.h> 

@interface detailview : UIViewController 
    { 

     IBOutlet UILabel *lblText; 
     NSString *selectedVehicle; 
    } 
@property (nonatomic, retain) NSString *selectedVehicle; 

@end 

これは詳細です。

#import "detailview.h" 

@implementation detailview 
@synthesize selectedVehicle; 

答えて

0

Xcode 4.2には、実装しようとしているマスター/ディテールアプリケーションの開始点を提供するMaster-Detail Applicationプロジェクトテンプレートがあります。

+0

百万分の1 –

関連する問題