2014-07-20 50 views
0

我試圖使UIActionSheet調用中的按鈕轉到其他視圖控制器。這是迄今爲止的代碼,它只是崩潰。我得到的錯誤信息是''Receiver()沒有標識符'Town'的延續''「UIActionSheet按鈕插入到新的ViewController中

- (IBAction)CategorizeButton:(id)sender { 
UIActionSheet* AS = [[UIActionSheet alloc]initWithTitle:@"Group by" 
               delegate:self 
             cancelButtonTitle:@"Cancel" 
           destructiveButtonTitle:nil 
             otherButtonTitles:@"Town",@"Title",@"Location", nil]; 
[AS showInView:self.view]; 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) 
    { 
     [self performSegueWithIdentifier:@"Town" sender:self]; 
    } 
    if (buttonIndex == 1) 
    { 
     [self performSegueWithIdentifier:@"Title" sender:self]; 
    } 
    if (buttonIndex == 2) 
    { 
     [self performSegueWithIdentifier:@"Location" sender:self]; 
    } 
} 


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    NSString* CategorizeTown = @"Town"; 
    NSString* CategorizeTitle = @"Title"; 
    NSString* CategorizeLocation = @"Location"; 

    if ([[segue identifier] isEqualToString:CategorizeTown]) 
    { 
     CategoryTableViewController* CAT = [segue destinationViewController]; 
     // blah blah 
    } 
    if ([[segue identifier] isEqualToString:CategorizeTitle]) 
    { 
     CategoryTableViewController* CAT = [segue destinationViewController]; 
     // blah blah 
    } 
    if ([[segue identifier] isEqualToString:CategorizeLocation]) 
    { 
     CategoryTableViewController* CAT = [segue destinationViewController]; 
     // blah blah 
    } 
} 
+0

提供有關崩潰的細節。包括哪一行導致崩潰以及完整且確切的錯誤消息。 – rmaddy

+0

@rmaddy當它到達其中一個時,它會崩潰[self performSegueWithIdentifier:@「Town」sender:self]; –

+0

您忘記添加有關錯誤消息的詳細信息。 – rmaddy

回答

2

在故事板中,選擇segue。

enter image description here

給它一個識別碼,(在你的情況,@ 「鎮」,@ 「標題」,@ 「位置」)

enter image description here

+0

@Mladen Kajic,你好,你會接受我的回答嗎? – ukim