0
當我添加一個子視圖時,它崩潰了我的應用程序。繼承人會發生什麼情況: 視圖在另一個類中加載調用方法,然後該類在原始類中調用sortDataIntoSubs。然後,它試圖添加一個子視圖,但它崩潰,因爲我相信它循環引起對象超出數組問題的代碼。我該怎麼辦?添加一個視圖到子視圖崩潰我的應用程序
- (void)viewDidLoad
{
searchText = [searchText uppercaseString];
self.title = searchText;
Download_Data *dwnLD = [[Download_Data alloc]init];
NSDate *finishDate = [NSDate date];
NSDate *startDate = [NSDate date];
NSDateComponents *dayComponent = [[[NSDateComponents alloc] init] autorelease];
dayComponent.day = -1;
NSCalendar *theCalendar = [NSCalendar currentCalendar];
startDate = [theCalendar dateByAddingComponents:dayComponent toDate:finishDate options:0];
[dwnLD downloadCSVFile:searchText startDate:startDate finishDate:finishDate key:1];
[super viewDidLoad];
}
-(void) sortDataIntoSubs:(NSMutableArray *) arrMTemp
{
NSMutableArray *arrDate = [[NSMutableArray alloc] init];
NSMutableArray *arrOpen = [[NSMutableArray alloc] init];
NSMutableArray *arrHigh = [[NSMutableArray alloc] init];
NSMutableArray *arrLow = [[NSMutableArray alloc] init];
NSMutableArray *arrClose = [[NSMutableArray alloc] init];
NSMutableArray *arrVolume = [[NSMutableArray alloc] init];
NSMutableArray *arrAdjClose = [[NSMutableArray alloc] init];
//Add every 7th object to the arrDate array.
[self setUpView];
}
-(void)setUpView
{
CGRect screenBound = [[UIScreen mainScreen] bounds];
UISegmentedControl *segMeg = [[UISegmentedControl alloc]init];
segMeg.center = CGPointMake(screenBound.size.width/2,screenBound.size.height/2);
segMeg.segmentedControlStyle = UISegmentedControlStylePlain;
NSArray *arrSegMeg = [NSArray arrayWithObjects:@"1w",@"2w",@"8w",@"16w",@"25w", nil];
[segMeg initWithItems:arrSegMeg];
[self.view addSubview:segMeg]; //This crashes
}
視圖由導航控制器處理。
我剛剛這樣做。 – JH95 2012-07-30 22:26:35