2014-09-30 48 views
0

我是編程應用程序的新手,雖然我有一個基本的句柄。 我想獲得用戶輸入的列數和行數,然後創建一個縮放比例以適合屏幕的圖像表(相同)。 然後,我希望能夠循環瀏覽並逐個更改顏色。Swift for iOS8中的動態圖像表

我可以在Python中編程(見下文),但我不知道如何以圖形的方式做到這一點。 想法?

print("Welcome to Well Tracker!") 
r=input('number of rows? ') 
while r.isdigit()!=True: 
    print('invalid try again') 
    r=input('number of rows? ') 
r=int(r) 
c=input('number of collumns? ') 
while c.isdigit()!=True: 
    print('invalid try again') 
    c=input('number of rows? ') 
c=int(c) 
print('\nTap enter to cross of a well, \nenter anything else to end\n') 
wellC=[0]*c 
def showWell(well): 
    print('The Well') 
    for i in well: 
     print(i) 

def fillNumbers(matrix): 
    for i in range(len(matrix)): 
     for j in range(len(matrix[i])): 
      matrix[i][j]=j+1 
    return matrix 

def makeWell(rows, collumns): 
    i = 0 
    well=[] 
    while i<rows: 
     well+=[collumns[:]] 
     i+=1 
    well=fillNumbers(well) 
    return well 
wellPlate=makeWell(r,wellC) 
showWell(wellPlate) 


def crossOff(well): 
    end=''; 

    for col in range(len(well[0])): 
     row=0 
     while row < len(well): 
      end=input(); 
      if end != '': 
       return False 
      well[row][col]='x' 
      row+=1 
      showWell(well) 
def checkForX(well): 
    xs=0 
    for i in range(len(well)): 
     for j in range(len(well[i])): 
      if well[i][j] == 'x': 
       xs+=1 
    return xs 

def main(): 
    platesComplete=0 
    while True: 
     wellPlate=makeWell(r,wellC) 
     if crossOff(wellPlate) == False: 
      break 
     platesComplete+=1 
    wellsComplete=checkForX(wellPlate)+platesComplete*r*c 
main() 

回答

0

更新時間:

還好,我的建議是看使用UICollectionView。示例:

https://github.com/bluedome/DragToReorderCollectionView

+0

謝謝您的鏈接。我會通過它,但我不認爲這正是我所想... – N3ur0n 2014-09-30 21:07:38

+0

你只是尋求幫助創建用戶輸入並在您的代碼中訪問它?如果是這樣,請在我鏈接到的同一站點上快速完成提示計算器教程。 – 2014-09-30 21:14:06

+0

不完全(?)我想製作一個圖形網格,然後能夠循環並切換這些圖形與第二個圖像。我有多少行,多少列以及哪種方式循環(下行或下列)的用戶輸入。現在這是一個在屏幕上製作圖像的問題 – N3ur0n 2014-09-30 22:16:24