0
我試圖從一個導航嵌入式視圖控制器的NSMutableArray發送到另一個的ViewController該方法的ios5從calloutAccessoryControlTapped將數據傳遞到另一個控制器
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{NSLog(@"tapped %@ %d",view.annotation.title,[res count]);
gpDetailViewController *gpDetailView = [[gpDetailViewController alloc] init];
gpDetailView.title = @"Details";
gpDetailView.detailArray = res;
[self.navigationController pushViewController:gpDetailView animated:YES];
}
之後被執行。 這裏是gpDetailViewController的接口和實現文件。
//
// gpDetailViewController.h
// livewell prototype
//
// Created by MyOxygen Mobile on 02/05/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface gpDetailViewController : UIViewController{
NSMutableArray *detailArray;
}
@property (nonatomic,retain) NSMutableArray *detailArray;
@end
和gpDetailViewController.m
//
// gpDetailViewController.m
// livewell prototype
//
// Created by MyOxygen Mobile on 02/05/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "gpDetailViewController.h"
@interface gpDetailViewController()
@end
@implementation gpDetailViewController
@synthesize detailArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
detailArray = [[NSMutableArray alloc]init];
NSLog(@"%@",[self.detailArray count]);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
我得到當我試圖打印數組元素的大小空值。 可能是什麼原因?