2016-04-26 78 views
-1

在我的應用程序,我想基於IBActions.here加載我的細胞是我的兩個IBActions,如何將值分配給iOS中的不同IBActions?

-(IBAction)action1:(id)sender 
{ 
} 

-(IBAction)action2:(id)sender 
{ 
} 

我想加載這樣

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (value == 0) 
{ 
    return 96; 
} 
else if(value == 1) 
{ 
    return 237; 
} 
return 0; 
} 

如何將我的價值= 0分配給我的action1和value = 1到我的action2?

+0

的標籤屬性實際上你想要什麼? – riddhi

+0

@IOSDeveloper。我如何將我的值= 0分配給我的action1和value = 1到我的action2? –

+0

@ User558你擁有一切......就這樣做。 – TheTiger

回答

3
-(IBAction)action1:(id)sender 
    { 
    self.value = 0 
    self.tableView.reloadData() 
    } 
+1

感謝您的reply.it工作正常 –

1

下面寫代碼

-(IBAction)action1:(id)sender 
{ self.value = 0 
    self.tableView.reloadData() 
} 

-(IBAction)action2:(id)sender 
{ 
    self.value = 1 
    self.tableView.reloadData() 
} 
0

沒有必要創建兩個方法,你可以使用的UIButton類

-(IBAction)action1:(UIButton *)sender 
{ 
    if (sender.tag == 0) 
    { 
     self.value = 0; 
    } 
    else 
    { 
     self.value = 1; 
    } 

    self.tableView.reloadData() 
} 
相關問題