【发布时间】:2016-01-03 06:18:21
【问题描述】:
以下是我的代码,没有错误但选择器没有响应。
ExampleTableviewSubProductDetail.h
中的代码@protocol EnterAmountDelegate <NSObject>
-(void)titlechange:(NSInteger)amount;
@end
@class ASIFormDataRequest;
@interface ExampleTableviewSubProductDetail : UIViewController<UIScrollViewDelegate>
{
}
@property (nonatomic, strong) id <EnterAmountDelegate>delegate;
ExampleTableviewSubProductDetail.m
中的代码 @implementation ExampleTableviewSubProductDetail
@synthesize delegate;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if([delegate respondsToSelector:@selector(titlechange:)])
{
//send the delegate function with the amount entered by the user
[delegate titlechange:20];
}
HostProductdetailViewController.h中的代码
#import "ViewPagerController.h"
#import "ExampleTableviewSubProductDetail.h"
@interface HostProductdetailViewController : ViewPagerController <ViewPagerDataSource, ViewPagerDelegate, EnterAmountDelegate>
{
}
HostProductdetailViewController.m中的代码
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSource = self;
self.delegate = self;
}
-(void)titlechange:(NSInteger)amount
{
NSLog(@"sdfsf");
}
在viewwillapper下面的Line总是返回false
if([delegate respondsToSelector:@selector(titlechange:)])
如果我遗漏了什么,请告诉我。
谢谢
【问题讨论】:
-
ViewPagerController的类层次结构是什么?
标签: ios iphone methods delegates delegation