我是iPhone開發人員的初學者,無法創建可展開的視圖。就像點擊tableview行一樣,它們擴展到更多行。我想用一些標題創建兩個標題,當用戶首先點擊,然後他們的詳細視圖打開時,agin點擊詳細視圖就會隱藏動畫。第二個標題相同。如何在不使用iOS中的tableview的情況下創建展開式視圖
這兩個標題之間應該有一些區別。 請幫幫我。我在這個鏈接的圖片中找到了關於我的需求的鏈接,但無法實現。
我是iPhone開發人員的初學者,無法創建可展開的視圖。就像點擊tableview行一樣,它們擴展到更多行。我想用一些標題創建兩個標題,當用戶首先點擊,然後他們的詳細視圖打開時,agin點擊詳細視圖就會隱藏動畫。第二個標題相同。如何在不使用iOS中的tableview的情況下創建展開式視圖
這兩個標題之間應該有一些區別。 請幫幫我。我在這個鏈接的圖片中找到了關於我的需求的鏈接,但無法實現。
你可以有一個UIView其高度爲0,然後展開它在你的按鈕,當點擊:
UIView *expandableView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,0)];
expandableView.backgroundColor = [UIColor redColor];
expandableView.alpha = 0;
然後當你點擊這個按鈕,你做一個動畫
[self.view addSubview:expandableView];
CGRect newFrame = expandableView.frame;
newFrame.size.height = 100;
//If this is the first view you would have to move the second header below
CGRect newHeaderFrame = header2.frame;
newHeaderFrame.origin.y += expandableView.frame.size.height;
[UIView animateWithDuration:0.3 animations:^{
expandableView.frame = newFrame;
expandableView.alpha = 1;
header2.frame = newHeaderFrame;
}];
而且當你想縮小它:
CGRect newFrame = expandableView.frame;
newFrame.size.height = 0;
//If this is the first view you would have to move back to header 2
CGRect newHeaderFrame = header2.frame;
newHeaderFrame.origin.y -= newFrame.size.height;
[UIView animateWithDuration:0.3 animations:^{
expandableView.frame = newFrame;
expandableView.alpha = 0;
header2.frame = newHeaderFrame;
} completion:^{
[expandableView removeFromSuperview];
}];
爲什麼你不能使用一個表視圖,如果你知道該怎麼做? – Wain
感謝您的回覆,其實只有兩個標題在我的情況下,在他們的點擊一個細節視圖打開他們的底部,並再次隱藏點擊該標題,我可以創建相同的圖像顯示在這個http:// stackoverflow。 com/questions/1944428/how-to-implement -a-accordion-view-for-iphone-sdk-app。如果是的請引導我,我也想確認我可以在我的項目中使用https://github.com/appsome/AccordionView Library並根據我的要求對其進行修改。請幫幫我。 – KDRocks