Ios Xcode-segue工作,然后后退按钮使应用程序崩溃

Ios Xcode-segue工作,然后后退按钮使应用程序崩溃,ios,objective-c,iphone,uibutton,segue,Ios,Objective C,Iphone,Uibutton,Segue,我有一个TopicsViewController,它显示学生热门研究主题标记的UI按钮 TopicsViewController: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"abortionSeg"]) { StatsViewController *statScreen = [segue destinat

我有一个TopicsViewController,它显示学生热门研究主题标记的UI按钮

TopicsViewController:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}

TopicsViewController.m有一个prepareForSegue方法,该方法成功地将数据传递给my StatsViewController,该方法显示所选主题的按统计信息标记的UIButtons。这些统计信息是从TopicsViewController类传递到StatsViewController类中的NSString属性的NSString

在TopicsViewController.m:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}
StatsViewController:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}

StatsViewController.m有一个prepareForSegue方法,该方法成功地将数据传递给我的CiteViewController,该控制器显示由所选统计数据的MLA和APA引用标记的UI按钮。这些引用的传递方式与统计数据从一个类传递到另一个类的方式相同

在StatsViewController.m:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}
CiteViewController:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}

然后,引用页面将URL传递给SourceViewController,以显示与源关联的UIWebView,但此页面没有问题

问题:

点击统计页面上的“

调试器显示TopicsViewController上的UI按钮为零:

点击Cite页面上的“

调试器显示StatsViewController上的NSString为零:


这就是我所发现的一切。提前感谢您的回复,非常感谢。

您是否分别前进和后退了?什么是“城市whichstate”?看起来,它要么没有正确声明,要么有垃圾值?崩溃日志的前两行说了什么?@Tj3n是的,单独的片段,一个从后退按钮连接到上一个视图@WasimSafdar
citeWhichStat
通过每个类来确定除了哪个主题之外还选择了哪个stat。这样就可以传递适当的内容@rptwsthi
self=(StatsViewController*)0x7fb66b45b620
segue=(UIStoryboardSegue*)0x7fb66b50f390
是前两行。单独的segue是错误的,如果要返回到最后一个屏幕,请使用委托或展开segue。您是否使segue分别向前和向后移动?什么是“城市whichstate”?看起来,它要么没有正确声明,要么有垃圾值?崩溃日志的前两行说了什么?@Tj3n是的,单独的片段,一个从后退按钮连接到上一个视图@WasimSafdar
citeWhichStat
通过每个类来确定除了哪个主题之外还选择了哪个stat。这样就可以传递适当的内容@rptwsthi
self=(StatsViewController*)0x7fb66b45b620
segue=(UIStoryboardSegue*)0x7fb66b50f390
是前两行。单独的segue错误,如果要返回到最后一个屏幕,请使用委派或展开segue