デリゲートを使用して、あるビューから別のビューに情報を渡していますが、テーブルビューセルを選択すると、データをデリゲートに渡して情報をスタックビューに戻します。それはビューに戻りますが、ビューが変わるとデリゲートメソッドに実際には入りません。デリゲートメソッドがアクセスされていません
ここで私の代理人を設定します。
subViewController.h
#import <UIKit/UIKit.h>
@protocol PassSubSearchData <NSObject>
@required
- (void) setModSearchFields:(NSArray *)modArray modIndexPath:(NSIndexPath *)modIndexPath setSubMod:(NSArray *)subModArray subModIndexPath:(NSIndexPath *)subModIndexPath;
@end
//...
//Delegate for passing Model and SubModel data back to VehicleSearchViewController
id <PassSubSearchData> delegate;
//...
//Delegate for passing Model and SubModel data back to VehicleSearchViewController
@property (strong) id delegate;
//これは私がそれを使用する方法です
subViewController.mその後
#import "MainViewController.h"
#import "SubViewController.h"
@implementation VehicleSubResultViewController
//...
//Delegate for passing Model and SubModel data back to VehicleSearchViewController
@synthesize delegate;
//...
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Access selected cells content (cell.textLabel.text)
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//Predicates restrict the values that will be returned from the query
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"SUB",cell.textLabel.text];
filterArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];
[[self delegate] setModSearchFields:tempModArray modIndexPath:tempModIndexPath setSubMod:filterArray subModIndexPath:indexPath];
//This pops to the VehicleSearchViewController view
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}
メインビューで
MainViewController.h
#import "SubViewController.h"
@interface VehicleSearchViewController : UITableViewController <PassSubSearchData> {
//...
MainViewController.m //しかしこのコードの一部は、私はちょうど、誰もが任意の助けをいただければ幸いです知っていれば私が欠けているかわからないんだけど、
- (void) setModSearchFields:(NSArray *)modArray modIndexPath:(NSIndexPath *)modIndexPath setSubMod:(NSArray *)subModArray subModIndexPath:(NSIndexPath *)subModIndexPath
{
modObjectString = [[modArray valueForKey:@"MOD"] objectAtIndex:0];
modIndexPath = modIndexPath; // Sets the selected IndexPath from the subview
subModObjectString = [[modelArray valueForKey:@"SUBMODEL"] objectAtIndex:0];
subModIndexPath = subModResultIndexPath; // Sets the selected IndexPath from the subview
NSLog(@"%@", modObjectString);
NSLog(@"%@", modIndexPath);
NSLog(@"%@", subModObjectString);
NSLog(@"%@", subModIndexPath);
[self.tableView reloadData];
}
ので、それをthatsの
にアクセスされることはありません。
NSLogのシリーズのすべてが欠落していますか?あなたのメソッドdidSelectRowAtIndexPathでは、値の2つ(tempModArrayとtempModIndexPath)がどこから来ているのかは不明です。それは何が欠けているのですか? –