喜欢&注释按钮然后将其保存到解析

时间:2014-09-21 22:48:33

标签: ios ios7

有谁知道如何在tableview页脚下实现这些按钮然后保存并进行解析?

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    NSString *cellidentifier=@"footer";
    UITableViewCell *footer = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    UIView* FView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)];
    UIButton *like = (UIButton *)[footer viewWithTag:1];
    [button addTarget:self action:@selector(buttonwastapped:) forControlEvents:UIControlEventTouchUpInside];
    [FView addSubview:self.like];
    return [FView autorelease];
}

- (void)buttonwastapped:(UIButton*)sender
   {

    PFUser *user = [PFUser currentUser];
    PFRelation *relation = [user relationForKey:@"likes"];
    [relation addObject:post];
    [user saveInBackground];

} //i try to use that but nothing happened 

1 个答案:

答案 0 :(得分:0)

如果你想在页面的页脚视图中添加按钮,可以在视图中创建一个按钮(如评论或注释)并添加目标。似乎你在其他地方分配按钮。没有用来检索uitableview单元格。示例代码:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{

    UIView* FView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)];
    UIButton *likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    likeBtn.frame = CGRectMake(0, 0, 30, 40); // set your btn frame
    [likeBtn addTarget:self action:@selector(buttonwastapped:) forControlEvents:UIControlEventTouchUpInside];
    [FView addSubView:likeBtn];

    return [FView autorelease];
}