Segue在故事中表演

时间:2015-05-02 22:12:43

标签: ios objective-c iphone

我有三个ViewControllers。首先我打开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标识符。我也尝试用导航控制器来呈现它,但它也不起作用。

0 个答案:

没有答案