gpt4 book ai didi

ios5 将数据从 calloutAccessoryControlTapped 传递到另一个 Controller

转载 作者:行者123 更新时间:2023-11-29 04:40:50 27 4
gpt4 key购买 nike

在此方法之后,我尝试将 nsmutablearray 从一个导航嵌入式 View Controller 发送到另一个 View Controller

- (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的接口(interface)和实现文件。

//
// 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

当我尝试打印数组元素大小时,我得到一个空值。可能是什么原因?

最佳答案

而不是

NSLog(@"%@",[self.detailArray count]);

试试这个

NSLog(@"%d",[self.detailArray count]);

count 是一个整数,而不是一个类

关于ios5 将数据从 calloutAccessoryControlTapped 传递到另一个 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10418025/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com