I don't know what is wrong with the app it was working fine until I tried to change stuff with the textlabel to textview then it crashed. So I tried changing it back to when it worked and it still crashes. Any ideas?
#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 file:
#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
I think you missed this:
In your example it should be the labelstext and the button too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.