Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从未调用iOS委托方法_Ios_Objective C_Delegates_Protocols - Fatal编程技术网

从未调用iOS委托方法

从未调用iOS委托方法,ios,objective-c,delegates,protocols,Ios,Objective C,Delegates,Protocols,我遇到了一个从未调用委托方法的问题。调用了goBack函数,但没有调用closeShopDetailView 我试图在HBShopDetailView中按下一个按钮,告诉HBShopsVC淡出HBShopDetailView子视图。我以前使用过类似的委托模式,但没有任何问题,所以我不确定这为什么不起作用。我已经看了关于这个话题的其他问题,他们的解决方案对我来说也不管用 我感谢所有的帮助 HBShopDetailView.h @protocol HBShopDetailDelegate <N

我遇到了一个从未调用委托方法的问题。调用了
goBack
函数,但没有调用
closeShopDetailView

我试图在
HBShopDetailView
中按下一个按钮,告诉
HBShopsVC
淡出
HBShopDetailView
子视图。我以前使用过类似的委托模式,但没有任何问题,所以我不确定这为什么不起作用。我已经看了关于这个话题的其他问题,他们的解决方案对我来说也不管用

我感谢所有的帮助

HBShopDetailView.h

@protocol HBShopDetailDelegate <NSObject>
- (void)closeShopDetailView;
@end


@interface HBShopDetailView : UIView

@property (nonatomic, weak) id<HBShopDetailDelegate> delegate;
@property (nonatomic, strong) IBOutlet UILabel *name;
@property (nonatomic, strong) IBOutlet UILabel *address;
@property (nonatomic, strong) IBOutlet UIImageView *logo;

- (id)initWithShopInformation:(PFObject *)shopInfo;

@end
@interface HBShopsVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, HBShopDetailDelegate>

@end

goBack:
方法中,
self.delegate
是否为非nil?在尝试调用该方法时,委托属性是否可能为nil?尝试在goBack方法中放置一个断点,并查看…明显的问题,但它是
self.delegate
nil
?就在
id strongDelegate=self.delegate的下方重写setDelegate并在那里放置断点。。可能其他人正在调用它:)在
goBack:
方法中,
self.delegate
是否为非nil?在尝试调用该方法时,是否可能委托属性为nil?尝试在goBack方法中放置一个断点,并查看…明显的问题,但它是
self.delegate
nil
?就在
id strongDelegate=self.delegate的下方重写setDelegate并在那里放置断点。。也许有人在叫它:)
@interface HBShopsVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, HBShopDetailDelegate>

@end
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"touch on row %d", (unsigned)indexPath.row);

    self.shopDetailView = [[HBShopDetailView alloc] initWithShopInformation: self.filteredArray[indexPath.row]];
    self.shopDetailView.delegate = self;
    [self.view addSubview:self.shopDetailView];

    //Fade in the detailView
    self.shopDetailView.alpha = 0;
    [UIView animateWithDuration:0.5 animations:^{
        self.shopDetailView.alpha = 1;
    }];
}

- (void)closeShopDetailView
{
    NSLog(@"closedetailview");
    self.shopDetailView.alpha = 1;
    [UIView animateWithDuration:0.5 animations:^{
        self.shopDetailView.alpha = 0;
    }];
}