2009-10-22 56 views
0

我有三個不同寬度的UILabels,我想排列在一起。我如何更新框架的X值?以編程方式將UILabels彼此相鄰放置

這是我有:

UILabel *contractLabel = (UILabel *) [cell viewWithTag:200]; 
contractLabel.text = [board getDisplayLevel]; 

UILabel *contractSuit = (UILabel *) [cell viewWithTag:201]; 
contractSuit.text = [board getDisplayStrain]; 
contractSuit.textColor = [board getDisplayStrainColor]; 
contractSuit.hidden = NO; 
contractSuit.frame = CGRectMake(contractSuit.frame.origin.x = contractLabel.frame.origin.x + contractLabel.bounds.size.width + 3, contractSuit.frame.origin.y, contractSuit.frame.size.width, contractSuit.frame.size.height); // line 121 

UILabel *contractTail = (UILabel *) [cell viewWithTag:202]; 
contractTail.text = [board getDisplayContract]; 
contractTail.hidden = NO; 
contractTail.frame.origin.x = contractSuit.frame.origin.x + contractSuit.bounds.size.width + 3; // line 127 

都分配到幀失敗:

ViewBoards_ViewController.m:121: error: lvalue required as left operand of assignment 
ViewBoards_ViewController.m:127: error: lvalue required as left operand of assignment 

我在做什麼錯?謝謝。

回答

2

你有一個簡單的拼寫錯誤

contractSuit.frame = CGRectMake(contractSuit.frame.origin.x = contractLabel.frame.origin.x + contractLabel.bounds.size.width + 3, contractSuit.frame.origin.y, contractSuit.frame.size.width, contractSuit.frame.size.height); 

應該

contractSuit.frame = CGRectMake(contractSuit.frame.origin.x + contractLabel.frame.origin.x + contractLabel.bounds.size.width + 3, contractSuit.frame.origin.y, contractSuit.frame.size.width, contractSuit.frame.size.height); 
+0

謝謝,我只是看不出一個。 – 2009-10-22 23:26:21

+1

發生在我們身上。 =) – 2009-10-22 23:27:04