簡體   English   中英

單擊按鈕動態彈出表格-iPhone

[英]Dynamically pop up table with button click - iPhone

我的視圖中有1個按鈕。 我想在同一視圖上單擊按鈕時彈出表格,並在單擊單元格時使其消失。 為此,需要ajax嗎? 還有其他選擇嗎?

NSString * title = @“ click”; NSArray * indexarr = [NSArray arrayWithObjects:@“ 1”,@“ 2”,@“ 3”,nil];

NSDictionary*dic1 = [NSDictionary dictionaryWithObject:@"one" forKey:@"1"];
NSDictionary*dic2 = [NSDictionary dictionaryWithObject:@"two" forKey:@"2"];    
NSDictionary*dic3 = [NSDictionary dictionaryWithObject:@"three" forKey:@"3"];

NSArray *conntarr = [NSArray arrayWithObjects:dic1,dic2,dic3,nil];

NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:title,@"title",indexarr,@"index",conntarr,@"content",nil];
sleep(2);
return dic;

它可以用來在單擊按鈕時打開彈出窗口。

不,不需要Ajax。

將表視圖hidden屬性設置為FALSE並將其放在UIView Animation塊中以呈現或顯示表視圖。

同樣,如果在單擊表視圖時將其隱藏,則只需要在didSelectRowAtIndexPath:表視圖的委托方法上將表視圖的hidden屬性隱藏或設置為TRUE

另外,您還需要研究UIView Animations以學習如何為tableview設置動畫。

編輯:

您也可以參考本教程來學習UIView動畫:

http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial

編輯-2:

這是動畫的示例代碼。

這是您應該在按鈕單擊事件上編寫的代碼,用於顯示表格視圖:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

tableView.frame = tableViewFrame;
tableView.hidden = NO;

[UIView commitAnimations];

這是您應該在tableView的委托didSelectRowAtIndexPath方法上編寫的代碼。 在將選定的值分配給NSUserDefault或變量(應保留選定的tableView單元格值)之后,將編寫此代碼。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

tableView.frame = CGRectMake(0.0f,0.0f,0.0f,0.0f);
tableView.hidden = YES;

[UIView commitAnimations];

HTH。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM