iPhone開發筆記

2022-05-05 22:39:18 字數 1551 閱讀 8772

計算string串的畫素長度:

1 cgsize pollabelsize = [polname sizewithfont:[uifont boldsystemfontofsize:16] constrainedtosize:cgsizemake(maxfloat, maxfloat)];

2 cgsize podlabelsize = [podname sizewithfont:[uifont boldsystemfontofsize:16] constrainedtosize:cgsizemake(maxfloat, maxfloat)];

3float pollabelwidth = (pollabelsize.width <= 125) ? pollabelsize.width : 125;

4float podlabelwidth = (podlabelsize.width <= 125) ? podlabelsize.width : 125;

5 [pollabel setframe:cgrectmake(10, 0, pollabelwidth, 32)];

6 [pageheaderarrow setframe:cgrectmake(pollabelwidth + 20, 7, 30, 20)];

7 [podlabel setframe:cgrectmake(pollabelwidth + 60, 0, podlabelwidth, 32)];

利用這個函式可以根據string的畫素長度來確定lable或者其他控制項的width 和 height,從而實現lable的靈活定位.

使用設定view的背景

1 [self.view setbackgroundcolor:[uicolor colorwithpatternimage:[uiimage imagenamed:@"

bg.png

"]]];

2 [self.table setbackgroundcolor:[uicolor clearcolor]];

tableview預設是白色背景,如果要tableview的背景和底層view的背景顏色一致,需要將tableview的bgc clear一下.

讀取自定義的cell的方法

1

static nsstring *cellidentifier = @"

cell

";2 historicalreliablityviewcellstyle *cell = (historicalreliablityviewcellstyle *)[tableview dequeuereusablecellwithidentifier:cellidentifier];

3if(cell == nil)

4

首先定義相應cell的乙個識別符號(如@"cell"),這是乙個靜態字串. 然後符合蘋果reuse的特點,先在用對應識別符號標記的cell重用queue裡面查詢是否有可重用的cell,有就返回相應的cell,否則返回nil.這時就需要為這種識別符號標記的cell建立乙個cell例項.上面這個例子是從cell的xib檔案中讀取構建相應的cell.

獲取螢幕的邊界

iphone開發筆記

1 iphone的開發環境最好還是在mac os上進行,不過mac os是建立在free bsd openstep基礎上的,inux上邊很容易去建立開發環境,但是沒有mac os的xcode開發難度加大。2 iphone的使用的開發語言是obective c,它幾乎完全相容c的語法 不是c 3 雖然...

iphone 開發筆記二

11 iphone中變數值是否等於字串的判斷方法 objective c string1 isequaltostring 123 12 iphone的framework的目錄 mac developer platforms iphoneos.platform developer sdks iphon...

iPhone開發筆記(三)

11 iphone中變數值是否等於字串的判斷方法 objective c string1 isequaltostring 123 12 iphone的framework的目錄 mac developer platforms iphoneos.platform developer sdks iphon...