我必須開發一個iPad電視指南,看起來像 What's On TV。iPad電視指南應用程序
我嘗試使用一個UITableView與許多行作爲信道的數量來做到這一點。爲了創建一種網格,我爲包含所有程序的每一行添加了一個子視圖(具有不同大小的UIButton)。爲了滾動視圖水平我加入手勢識別和每次我向右或向左滑動時間改變了UIView(子視圖小區)位置。
這樣的作品,但解決的辦法在我看來有點亂,動畫也不是那麼活潑。你有什麼想法(或例子)來獲得更好的解決方案嗎?那html5呢?
感謝
我的代碼:
在ViewController.m- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
_chName = (UILabel *)[cell viewWithTag:4];
_chName.text=((Channel *)[_resultEPGChannel objectAtIndex:indexPath.row]).name;
_viewCell = (UIView *)[cell viewWithTag:2];
_viewCell.frame=CGRectMake(-_positionView, 0,2000, 77);
//add the view to the _viewCell (moving view) with the right program for each channel (row)
cp = [[ChannelProgram alloc] init] ;
cp.allProgram=[_resultEPGProgram objectAtIndex:indexPath.row];
[_viewCell addSubview:cp];
return cell;}
在ChannelProgram.m(UIView的子類)
- (void)drawRect:(CGRect)rect{
int xPoint=2;
for (Program *singleProgram in allProgram) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.backgroundColor=[UIColor lightGrayColor];
[button setTitle:singleProgram.title forState:UIControlStateNormal];
button.frame=CGRectMake(xPoint,0, singleProgram.lengthProgram,75);
[self addSubview:button];
xPoint = xPoint+singleProgram.lengthProgram+2;}
這是非常緩慢的動畫,每次我不得不重新加載表格時變得最差。怎麼了?
通過分析器運行程序。 – Edwin