我需要具有自定義標題視圖的表格視圖。當我觸摸這個標題視圖時,我會讓她調整大小。我有下一個代碼(例如)類topBarViewController
:智能UITableView標題視圖
topBarViewController類:
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.frame = CGRectMake(0, 0, 320, 48);
[self.view setBackgroundColor:[UIColor greenColor]];
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
}
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer
{
[UIView animateWithDuration:0.5 animations:^{
CGRect frame = self.view.frame;
frame.size.height+=50;
self.view.frame = frame;
} completion:^(BOOL finished) {
}];
}
然後我設置此視圖作爲我的表視圖頭視圖。在觸摸事件我碰到了下一個文字:
2014-10-05 01:00:07.580 UGTUMap[4715:1988098] -[UITransitionView handleSingleTap:]:
unrecognized selector sent to instance 0x7ff6d542a5f0
2014-10-05 01:00:07.586 UGTUMap[4715:1988098] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UITransitionView handleSingleTap:]:
unrecognized selector sent to instance 0x7ff6d542a5f0'
找不到解決方案。有什麼建議麼?
顯示在您創建'topBarViewController',並將它設置爲表視圖的標題代碼視圖。我的猜測是,你創建'topBarViewController',使用它的視圖,但從來沒有保持強大的引用視圖控制器('topBarViewController'實例)。 – rmaddy 2014-10-04 21:38:29
@rmaddy謝謝你,強烈的參考是一個解決方案! – 2014-10-04 21:57:04