2013-03-06 131 views
0

我不知道什么是错误的应用程序它工作正常,直到我试图改变东西与textlabel textview然后坠毁。所以我试着将它改回原来的状态,它仍然崩溃。有任何想法吗?当我在模拟器上运行iphone应用程序,屏幕是白色的

#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 
+0

您必须链接故事板中的UILabel插座。 – 2013-03-06 00:23:21

+0

@Jacob你遇到了什么事故? – DGund 2013-03-06 00:27:31

+0

通常,花一分钟时间来了解Xcode或GIT中的快照。这样,当你做出一个糟糕的变化时,你将能够放松回到已知的工作状态。 – GoZoner 2013-03-06 00:29:10

回答

0

我想你错过了这一点:

在你的榜样应该是labelstext和按钮了。

enter image description here

+0

好的,我应该怎样改变代码,我做了你在图片中做的。我仍然有问题。 – jacobohunter 2013-04-09 20:16:28

相关问题