2011-12-04 81 views
1

我正在使用以下語句來解除UIActionsheet與UIPickerView,爲其定義了一個關閉按鈕。爲什麼UIActionSheet是自動發佈的?

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];  

UIActionsheet會自動解除關閉按鈕之前可以點擊?我有一個理論,爲什麼這是因爲UIActionsheet是通過按鈕來調用的,並且這個按鈕是在UIActionsheet被啓用之後立即廢除的。我如何確保closebutton是上述語句中引用索引的按鈕?如何找到我編程創建的closebutton的索引?

回答

0

由於UIActionSheet沒有「closebutton」我假設你的意思是「cancelButton」。你會這樣做:

[actionSheet dismissWithClickedButtonIndex:[actionSheet cancelButtonIndex] animated:YES]; 
+0

我已經添加了一個關閉按鈕。 (下面)。指定的代碼與「取消」按鈕一起工作,但我不想在UIPicker.UISegmentedControl * closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@「Done」]]]中使用此代碼。 closeButton.momentary = YES; closeButton.frame = CGRectMake(260,7.0f,50.0f,30.0f); closeButton.segmentedControlStyle = UISegmentedControlStyleBar; closeButton.tintColor = [UIColor blackColor]; [closeButton addTarget:self action:@selector(dismissActionSheet :) forControlEvents:UIControlEventValueChanged]; – Shaddy