我试图在UIActionSheet
调用segue上设置按钮,这些按钮会转到其他视图控制器。这是我到目前为止的代码,它只是崩溃。我收到的错误消息是"'接收者()没有带标识符的segue' Town''"
- (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 :(得分:2)
在故事板中,选择segue。
给它一个标识符,(在你的情况下,@" Town",@" Title",@" Location")