0

我不知道应用程序有什么问题,它运行良好,直到我尝试将带有 textlabel 的内容更改为 textview 然后它崩溃了。所以我试着把它改回它工作的时候,它仍然崩溃。有任何想法吗?

 #import "TestViewController.h"

@implementation TestViewController

@synthesize labelsText;


-(void)setup {
    titles = [NSArray arrayWithObjects:@"Title 1",@"Title 2",@"Title 3",@"Title 4", nil];
}



-(IBAction) nextclicked:(id)sender{
    titles = [NSArray arrayWithObjects:@"iology is the scientific study of life. Bam",@"This works? Wow",@"Still Works.",@"garret is the coolest awesome person awesome wowowowwwwwwwwwwwwwwwwwwwwwwwwwww", nil];
        if (step<titles.count-1) {
        step++;
    }
    else
    {
        step= 0;
    }
    labelsText.text = [titles objectAtIndex:step];
    }  



-(IBAction) prevClicked:(id)sender{
    titles = [NSArray arrayWithObjects:@"Biology is the scientific study of life. Bam",@"This works? Wow",@"Still Works.",@"garret is the coolest awesome person awesome wowowowwwwwwwwwwwwwwwwwwwwwwwwwww", nil];
    if (step>0) {
        step--;
    }
    else
    {
        step =titles.count-1;
    }
    labelsText.text = [titles objectAtIndex:step];
    }  



- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
        self.labelsText=nil;
}


- (void)dealloc {
    [super dealloc];
    [labelsText release];
}

@end

.h 文件:

#import <UIKit/UIKit.h>

@interface TestViewController : UIViewController {
        UILabel *labelsText;
    UIButton *btn;
    int step;
    NSArray *titles;
                }
@property (nonatomic, retain) UILabel *labelsText;
 -(IBAction) nextclicked:(id)sender;
-(IBAction) prevClicked:(id)sender;



    @end
4

1 回答 1

0

我想你错过了这个:

在您的示例中,它也应该是标签文本和按钮。

在此处输入图像描述

于 2013-03-06T00:29:56.803 回答