我有一个ViewController有两个segues,我希望segue在从URL获取数据后呈现viewcontroller。所以我在Xcode 6
方法中保留了update_attributes
。
但我只能显示第一个viewcontroller。
我希望两个segues都正常工作。
before_save
答案 0 :(得分:1)
如果你这样做,我相信你应该得到你需要的结果。
为按钮设置IBOutlets button1和button2,为按钮设置IBAction方法,并将其selected属性设置为YES。
- (IBAction)button1Clicked:(id)sender
{
button1.selected = YES;
if (button2.selected)
{
// This is done so that both buttons do not appear as clicked at the same time
button2.selected = NO;
}
}
- (IBAction)button2Clicked:(id)sender
{
button2.selected = YES;
if (button1.selected)
{
// This is done so that both buttons do not appear as clicked at the same time
button1.selected = NO;
}
}
完成此操作后,在您的connectionDidFinishLoading方法中执行此检查。
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *teststr=[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSString *str1234 = [teststr stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSLog(@"Response is %@ %lul",str1234,(unsigned long)
[str1234 length]);
[alert dismissWithClickedButtonIndex:0 animated:YES];
if (button1.selected)
{
[self performSegueWithIdentifier:@"good" sender:self];
}
else if (button2.selected)
{
[self performSegueWithIdentifier:@"callback" sender:self];
}
}
希望它有所帮助。