テキストラベルの内容をテキストビューに変更しようとするまで正常に動作していたアプリの何が問題なのかわかりませんが、クラッシュしました。そのため、動作していたときの状態に戻そうとしましたが、それでもクラッシュします。何か案は?
#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