2013-03-06 132 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

相關問題