2014-09-30 53 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