我有三个ViewController。首先,我打开thirdViewController,并在thirdViewController中打开secondViewController。我使用segue执行seondViewController,但id不起作用。

#import "thirdViewController.h"
#import "ViewController.h"
#import "DetailViewController.h"
#import "secondViewController.h"


@interface thirdViewController (){
NSDictionary *currencies;
NSMutableArray *arrayCurrenciesKeys;
NSMutableData *webData;
NSURLConnection *connection ;
NSMutableArray *array;
NSMutableArray *temp;

}
@end


@implementation thirdViewController
@synthesize tableView,cityname;


- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"Типи валют";
[[self tableView]setDelegate:self];
[[self tableView]setDataSource:self];
array=[[NSMutableArray alloc]init];
      NSURL *url =[NSURL    URLWithString:@"http:resources.finance.ua/ua/public/currency-cash.json"];
NSURLRequest *request =[NSURLRequest requestWithURL:url];
connection= [NSURLConnection connectionWithRequest:request delegate:self];

if(connection)
{
    webData=[[NSMutableData alloc] init];
}


   tableView.backgroundColor=[UIColor clearColor];
   tableView.alpha=0.9;



   }

   -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
   {
    return 1;
   }
   -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:       (NSInteger)section
   {
   return [array count];
    }
   -(UITableViewCell*) tableView:(UITableView *)tableView        cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *CellIdentifier =@"Cell";                                UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if(!cell)
  {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  }

   cell.textLabel.text=[array objectAtIndex:indexPath.row];

   return cell;
 }


    -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
 {
  [webData setLength:0];

  }
  -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
   {
   [webData appendData:data];
   }
  -(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
   {
     NSLog(@"Error");
    }
   -(void) connectionDidFinishLoading:(NSURLConnection *)connection
   {

   NSDictionary *allDataDictionary = [NSJSONSerialization   JSONObjectWithData:webData options:0 error:nil];
NSDictionary *feed =[allDataDictionary objectForKey:@"organizations";

   for(NSDictionary *diction1 in feed){


   NSString *label1 = [diction1 objectForKey:@"cityId"];
   [temp addObject:label1];
   NSString *label2 =[[allDataDictionary objectForKey: @"cities" ] objectForKey:[NSString stringWithFormat:@"%@",label1]];
   if(![array containsObject:label2]){
       [array addObject:label2];}
   else{
       ;
   }

[[self tableView]reloadData];
   }

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

 [self performSegueWithIdentifier:@"Banks" sender:self];

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {

if ([[segue identifier] isEqualToString:@"Banks"])     {

}
 }




 - (void)didReceiveMemoryWarning
 {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
   }
 @end


另外,我在情节提要中添加了segue标识符。我也尝试将其与导航控制器一起呈现,但是它也不起作用。

最佳答案

我有三个ViewController。首先,我打开thirdViewController,并在thirdViewController中打开secondViewController。我使用segue执行seondViewController,但id不起作用。


我假设您的“第一个”是ViewController.h

1-您确定从thirdViewController到secondViewController的序列的标识符是@“ Banks”吗?

您可能会误以为它的标识符从ViewController转移到thirdViewController。

2-仔细检查您在Interface Builder和代码中是否具有完全相同的字符串。

在Interface Builder中,它可以是@“ Bankss”,在代码中可以是@“ Banks”。

10-07 20:43