gpt4 book ai didi

ios - Segue 在故事中表演

转载 作者:行者123 更新时间:2023-11-29 02:04:01 24 4
gpt4 key购买 nike

我有三个 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

我还在 Storyboard中添加了segue标识符。我也尝试用导航 Controller 来呈现它,但它也不起作用。

最佳答案

I have three ViewControllers. In first I open thirdViewController and in thirdViewController I open secondViewController. I use segue to perform seondViewController, but id doesn't work.

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

1- 您确定从 thirdViewController 到 secondViewController 的 segue 标识符是@"Banks"?

您可能会使用从 ViewController 到 thirdViewController 的 segue 标识符来误导它。

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

在Interface Builder中可以是@"Bankss",在代码中可以是@"Banks"。

关于ios - Segue 在故事中表演,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30008061/

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