从未调用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;
}];
}