How to add textfields on uicollection view?

坚强是说给别人听的谎言 提交于 2019-12-13 05:45:54

问题


i am doing a project ,where i have to show a view like this i tried to use table view ,but i was unable to implement ,after that i have decided to implement this with the help of collection view.but nothing fruitful happened .i get frustated here because nothing can happen with my view .these are the text fields added on the view and all are clickable,can anyone help me in this i am a fresher so please help me.


回答1:


    //////////////////
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        if(section==0)
        {
            return self.view_header;
        }

        return nil;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        CGFloat height =0.00;

        if(section==0)
        {
            height = 32;
        }     

        return height;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    {    

        if(indexPath.section == 1)
        {
            return 51; 
        }
        else
        {
            return 35;
        }
    }



    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

        if(self.flag_loadCompleted == TRUE)
        {
            return 1;
        }
        return 2;
    }


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  

        if(section == 0)
        {
            return [self.arr_data count];
        }
        else if(section == 1)
        {
            return 1;
        }

        return 0;
    }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    

    static NSString *CellIdentifier = @"MyTemplate";
    MyFinancialTemplate *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
    {
        cell = [MyFinancialTemplate createNewTextCellFromNib];
    }    
    cell.index = indexPath.row;  
    if(indexPath.section == 0)
    {
        cell.index = indexPath.row;
        cell.flag_loader = FALSE;

        cell.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    else
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.flag_loader = TRUE;
    }

    [cell LoadCell];

    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   

}


来源:https://stackoverflow.com/questions/17168749/how-to-add-textfields-on-uicollection-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!