我制作了一个Stock Tiker来显示连续的股票对象。一审工作正常。
票据代码的实现如下:
- (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];
}
//输出没问题
但是当我制作 Ticker 类的第二个实例时,它彼此重叠。
使用ticker.tag 管理的两个实例的输出
任何的想法?我该如何解决这个错误。提前致谢!
嘿,我上传了一个例子,请检查它水平列表