我正在使用CFViewController,我需要调用委托方法。
CFCoverFlowView.h
@class CFCoverFlowView;
@protocol CFCoverFlowViewDelegate <NSObject>
@optional
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didScrollPageItemToIndex:(NSInteger)index;
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didSelectPageItemAtIndex:(NSInteger)index;
@end
@interface CFCoverFlowView : UIControl
@property (nonatomic, weak) id <CFCoverFlowViewDelegate> delegate;
CFViewController.h
@class CFCoverFlowView;
@interface CFViewController : UIViewController <CFCoverFlowViewDelegate>{
int contador;
CFCoverFlowView *coverFlowView2;
}
CFViewContorller.m
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didScrollPageItemToIndex:(NSInteger)index {
NSLog(@"didScrollPageItemToIndex >>> %@", @(index));
self.pageControl.currentPage = index;
contador++;
if(contador == [computers count]){
contador = 0;
}
pageControl2.currentPage = contador;
NSLog(@"Scroll: %d", contador);
}
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didSelectPageItemAtIndex:(NSInteger)index {
NSLog(@"didSelectPageItemAtIndex >>> %@", @(index));
}
我需要在滚动页面时调用最后两个函数。就像你有一个UITableView
并且它调用了这个函数-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
有人可以帮助我吗?
谢谢你提前。
答案 0 :(得分:1)
添加以下行:
[coverFlowView2 setDelegate:self];
您已在coverFlowView2
中初始化CFViewController
。