2011-04-11 74 views
3

在我的應用程序中我從服務器獲取圖像,並且能夠在圖像視圖中顯示圖像.... 但現在我想要將從服務器獲取的圖像存儲在表格中在單擊表格視圖單元格的同時查看並顯示它們。我想要的是如何使圖像的縮略圖以顯示它在表格視圖單元格。如果我直接在表格視圖單元格中顯示圖像它是一些顯示笨拙的....因爲我想讓縮略圖該圖像和表格視圖單元格中顯示它...以編程方式創建圖像的縮略圖

任何一個可以幫我如何創建一個圖像編程......

回答

0
- (void) createThumbView { float y_axis = Set y axis; 

int x = 0; 

int totalImgs = total images; 

int tempCnt = 0; 

for (int i = 0; i < totalImgs;) 
{ 
    float x_axis = set x axis; 

    int loopCount = 0; 

    if (totalImgs - tempCnt >= (no of images in row)) 
    { 
     loopCount = (no of images in row); 
    } 
    else 
    { 
     loopCount = totalImgs % (no of images in row); 
    } 

    for (int j = 0; j < loopCount; j++) 
    { 
     MasksData *mData = [masksList objectAtIndex:x]; 

     UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
     btn.frame = CGRectMake(x_axis, y_axis, width, height); 
     [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mData.bgImage]] forState:UIControlStateNormal]; 
     btn.backgroundColor = [UIColor clearColor]; 
     btn.tag = x; 
     [scroll View addSubview:btn]; 

     //photoCount++; 
     x_axis += width + some space; 

     tempCnt++; 
     i++; 
     x++; 
    } 

    y_axis += height + some space; 

    scroll View.contentSize = CGSizeMake(320.0, y_axis); 
} 
+0

這是可以點擊縮略圖列表。 – 2011-04-11 13:17:48

+0

我該怎麼寫x軸和y軸和一些空間?或者我可以給任何東西進入 – 2013-04-08 08:52:25

+0

什麼是掩膜數據 – 2013-04-08 08:59:42