English 中文(简体)
未访问的代表方法
原标题:Delegate method not being accessed

我从一个角度向另一个使用代表的人传递了一些信息,然而,在我选择一个表象小组时,我向代表传递了数据,以便把信息反馈到对 st的看法中,从而回过了这一观点,但在意见改变时,实际上并没有进入代表方法。

在这方面,我设立了我的代表。

#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;

页: 1

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

主要意见 然而,法典的这一部分从未接触过。

- (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]; 
}

因此,如果任何人知道任何帮助,我就不敢肯定我所失踪的人。

最佳回答

这位代表很可能永远不会 set,因此是无所不在的。

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签