2012-10-21 95 views
1

我的應用程序只需調用一個UIActionSheet這樣的:UIActionSheet調用兩次?

UIActionSheet *dataCopySheet = [[UIActionSheet alloc] initWithTitle:@"Copy Element  Information" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Name", @"Melting Point", @"Boiling Point", @"Atomic Mass", @"Density", @"Discovery Info", @"Save Image", nil]; 
[dataCopySheet showInView:detailView]; 

出於某種原因,二UIActionSheets從這個顯示(一個出現在其他)。難道我做錯了什麼?

+0

您必須調用此代碼兩次。在上面的代碼中放置一個斷點並運行該應用程序。每次到達斷點時查看堆棧跟蹤以確定誰在調用以及爲什麼調用了兩次。 – rmaddy

+0

這是我嘗試的第一件事。它只被調用過一次,但仍然有兩次出現。 – JohnWickham

回答

3

好吧,想通了......我從UILongPressGestureRecognizer中調用了操作表,並且它被調用了兩次。我將它改爲UITapGestureRecognizer,現在只調用一次,效果很好。 UILongPressGestureRecognizer奇怪的問題。

+2

使用長按手勢識別器,您需要檢查其「狀態」。請參閱http://stackoverflow.com/questions/7907671/ios-uiactionsheet-presented-from-longpress-gesture-on-a-button-erroneously-requi。 – Anna