ITEEDU

iPhone书架设计根据数据源大小计算tableView行数

/*********************************************************************************
 函数: - (void)numberOfRow
 功能: 根据实际数据源的大小,计算tableview的行数
 参数:
 返回值:
 **********************************************************************************/  
-(void)numberOfRow
{
    if([self.listData count]%3 != 0)
        rowNum = [self.listData count]/3+1;          
    else
        rowNum = [self.listData count]/3;
}

/*********************************************************************************
 函数: - (void)didReceiveMemoryWarning 
 功能: 处理内存问题警告,此处代码自动生成
 参数:
 返回值:
 **********************************************************************************/  
- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

/*********************************************************************************
 函数: - (BOOL)shouldAutorotateToInterfaceOrientation:
 功能: 支持屏幕自动转向,此处代码自动生成
 参数: (UIInterfaceOrientation)interfaceOrientation
 返回值:布尔型的状态值
 **********************************************************************************/ 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


/*********************************************************************************
 函数: -(NSInteger)tableView: numberOfRowsInSection:
 功能: 返回numberOfRow函数所计算的值
 参数: (UITableView *)tableView (NSInteger)section
 返回值:rowNum
 **********************************************************************************/ 
-(NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section
{
    //[tableView backgroundView:];
    [self numberOfRow];
    return rowNum;
}

iPhone书架点击事件处理

/*********************************************************************************
 函数:-(void)btn:(id)sender
 功能: 书籍首页点击事件处理
 参数: (id)sender
 返回值:
 **********************************************************************************/ 
-(void)btn:(id)sender
{
    UIButton *cellView = (UIButton *)sender;
    NSLog(@"current tag=%d",cellView.tag);//将v.tag作为各种书籍首页的索引值
          
}