I made a Stock Tiker to display continuous stock objects. And Working fine for first Instance.
The implementation of the ticket code is as follows:
- (void)viewDidLoad
{
tickerView=[[StockTiker alloc] init];
[tickerView setFrame:CGRectMake(0, 0, 320, 20)];
tickerView.delegate=self;
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 20)];
[label setBackgroundColor:[UIColor redColor]];
label.text=@"First Object";
UILabel *label2=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
[label2 setBackgroundColor:[UIColor grayColor]];
label2.text=@"Second Object";
UILabel *label3=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
[label3 setBackgroundColor:[UIColor magentaColor]];
label3.text=@"Third Object";
UILabel *label4=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 75, 20)];
[label4 setBackgroundColor:[UIColor yellowColor]];
label4.text=@"Fourth Object";
UILabel *label5=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 75, 20)];
[label5 setBackgroundColor:[UIColor cyanColor]];
label5.text=@"Fifth Object";
viewArray=[[NSArray alloc] initWithObjects:label,label2,label3,label4,label5,nil];
[self.view addSubview:tickerView];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark- Ticker Delegate..
-(UIView*)viewForRow:(int)row inTicker:(StockTiker*)stock_Ticker
{
return [viewArray objectAtIndex:row];
}
-(int)numberOfRowsForStockTiker:(StockTiker*)stock_Ticker
{
return [viewArray count];
}
//Output is fine
But when I made second Instance of Ticker class it overlapped to each other.
Output with two instance managed using ticker.tag
Any Idea?
How can I solve this error.
Thanks in Advance!
Hey I have uploaded an example please check it Horizontal List