嗨,我在這裏開發小應用程序。在子類屏幕中,我有兩個按鈕。當我按下第一個按鈕時,它會顯示四個操作表。當我按下第二個按鈕時,它將顯示五個操作表。我成功地展示了它。但我不能設置五個動作表的第二個按鈕動作。在我的代碼中,當我按下第一個動作表的第二個按鈕時,它將啓動第一個動作表的第一個按鈕。在這裏,我想爲各個操作表設置操作。請幫助我。這裏是我的代碼是如何爲兩個按鈕創建不同的uiactionsheet?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0)
{
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Edit" otherButtonTitles:@"Remove", @"Sell",@"Scrap", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[popupQuery showInView:self.view];
[popupQuery release];
}
if (indexPath.row == 1)
{
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Unsell" otherButtonTitles:@"Edit Item", @"Edit Sale",@"Sold",@"Scrap", nil];
popupQuery.tag=5;
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.view];
[popupQuery release];
}
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
Updateasset *object=[[Updateasset alloc]initWithNibName:@"Updateasset" bundle:nil];
[self presentModalViewController:object animated:NO];
[object release];
}
else if (buttonIndex == 1)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Remove" message:@"Do you want to Remove"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
else if (buttonIndex == 2)
{
Egarageselling *object=[[Egarageselling alloc]initWithNibName:@"Egarageselling" bundle:nil];
[self presentModalViewController:object animated:YES];
[object release];
}
else if (buttonIndex == 3)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scrap" message:@"Do you want to Scrap"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
else if (buttonIndex == 4)
{
}
else if (buttonIndex == 5)
{
}
else if (buttonIndex == 6)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scrap" message:@"Do you want to Scrap"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
else if (buttonIndex == 7)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scrap" message:@"Do you want to Scrap"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
else if (buttonIndex == 8)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scrap" message:@"Do you want to Scrap"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
else if (buttonIndex == 9)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scrap" message:@"Do you want to Scrap"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
}
}
如何解決這個問題。
它會工作,但它也動作與第一個按鈕的動作表如何解決 –
我沒有得到你的觀點 – Narayana
這是我的代碼。 如果(indexPath.row == 0) \t { \t \t ... \t \t popupQuery.tag = 5; \t \t ..... \t} \t如果(indexPath.row == 1) \t { \t \t .... \t \t popupQuery1.tag = 6; \t \t ... \t} - (空)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger的)buttonIndex { \t \t如果(actionSheet。標籤= 5) \t { \t \t如果(buttonIndex == 0) \t \t { \t \t} \t} \t \t 如果(actionSheet.tag = 6) \t { \t \t如果(buttonIndex = = 0) \t \t { \t \t \t \t \t} \t \t等等 } –