CONFIGURATION內從一個UIView一個賽格瑞:使用協議來觸發一個UIViewController
- UIviewController
嵌入Navigationcontroller
。 - UIviewController
具有UIscrollview
作爲子視圖 - UIscrollview
具有在其中創建圖表一些視圖:含有圖表每個視圖有其自己的h和m文件和從該文件欲觸發SEGUE到的tableview控制器。 -A Tableviewcontroller
在xcode中加入和從UIviewController
到TableViewcontroller
一個SEGUE被創建以及(Xcode
)
-created在UIView
的協議有SEGUE從那裏推開。
問題:
代表總是零,賽格瑞方法永遠不會被調用
UIView的.h文件中
@protocol UItoUIvcDelegate <NSObject>
-(void)triggerSegue;
@end
@interface CFfirstGraph : UIView <CPTPlotDataSource , CPTPieChartDelegate,UIActionSheetDelegate>
@property(weak, nonatomic) id <UItoUIvcDelegate> delegate;
@end
的UIView .m文件(片段)
-(void)pieChart:(CPTPieChart *)pieChart sliceWasSelectedAtRecordIndex:(NSUInteger)index
{
if (self.delegate == nil)
{
NSLog(@"nil");
}
[self.delegate triggerSegue];
}
的UIViewController .h文件
#import "CFfirstGraph.h"
@interface CFMainViewController : UIViewController <UItoUIvcDelegate, UITableViewDelegate, UITableViewDataSource>
@end
的UIViewController .m文件(片段)
- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView.contentSize = CGSizeMake(320, 1000);
[self.view addSubview:self.scrollView];
CFfirstGraph *click =[[CFfirstGraph alloc]init];
click.delegate = self ;
}
-(void)triggerSegue
{
[self performSegueWithIdentifier:@"detailedData" sender:self];
NSLog(@"estoy aqui");
}
我在做什麼錯?爲什麼代表總是零?我試圖添加setDelegate方法,但仍然沒有運氣。
感謝, DOM
不,還是零,但感謝回答。我試圖移動viewDidAppear中的click和click.delegate行,但它也不起作用。我認爲這個協議是正確實現的,所以這個問題必須隱藏在scrollview和子視圖之間的某個地方。 –
你可以發送源代碼到[email protected]mail.com嗎? –