Each and every time you open the folder, you are creating separate instances of CLTickerView *ticker
and adding to the view as subview using this line [self.view addSubview:ticker];
. If you want to add that only once, you need to create the ticker in a place where you wont call the alloc
method repeatedly.
Create in viewDidLoad
or so,
CLTickerView *ticker = [[CLTickerView alloc] initWithFrame:CGRectMake(0, 35, 320, 35)];
Then use it as,
PFQuery *query = [PFQuery queryWithClassName:@"TestObject"];
[query getObjectInBackgroundWithId:@"object1"
block:^(PFObject *textu, NSError *error) {
if (!error) {
// start the tickerview
ticker.marqueeStr = [textu objectForKey:@"text"];
ticker.marqueeFont = [UIFont systemFontOfSize:26];
[self.view addSubview:ticker];
// if there's connection
} else {
// Log details of our failure
ticker.marqueeStr = @"Keine Internet Verbindung";
ticker.marqueeFont = [UIFont systemFontOfSize:26];
[self.view addSubview:ticker];
//if there's no connection;
}
}];
Remember that whenever you call CLTickerView *ticker = [[CLTickerView alloc] initWithFrame:CGRectMake(0, 35, 320, 35)];
, it creates separate copies and you cant access the previous one, once the new one is created.
Whenever you want to remove it just use [ticker removeFromSuperview];