2014-09-21 45 views
0

有誰知道如何在tableview腳本下實現這些按鈕,然後保存它和retreive解析?贊和評論按鈕,然後保存它來解析

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    NSString *[email protected]"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 
+0

頁腳中的按鈕?如果是這樣,是'buttonwastapped:'當選擇該按鈕時被調用? – 2014-09-22 01:26:57

+0

是啊,它被稱爲 – 2014-09-23 01:32:49

回答

0
,如果你想添加按鈕頁腳視圖部分的視圖中創建一個按鈕(如或註釋)頁腳,並添加目標

。似乎你正在其他地方分配按鈕。 theres沒有用於檢索uitableview cell.here是示例代碼:

- (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]; 
} 
相關問題