這是一個比其他任何問題更多的數學問題。我擁有的是一個動態數組對象,我在其中存儲用戶照片。uitableview numberOfRowsInSection count
arryData = [[NSArray alloc] initWithObjects:@"pic1.png", @"pic2.png", @"pic3.png", @"pic4.png", @"pic5.png", @"pic6.png",@"pic7.png", @"pic8.png",nil];
該陣列可以具有對象的任何量在它e.g 8或20或100。以我的表視圖我已經創建每行4周的UIImageViews通過將其添加到cell.contentview。所以,如果讓我們說
- 如果arryData有3個對象的話,我想UITable創建1行
- 如果arryData有4個對象,然後我想UITable創建1行
- 如果arryData有5個對象,然後我想UITable創建2行
- 如果arryData有8個目標,然後我想UITable創建2行
- 如果arryData有10個對象的話,我想UITable創建3行
- ....等等
那麼如何在我的arryData中爲N個對象執行此操作?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//NSLog(@"Inside numberOfRowsInSection");
//return [arryData count];
//Cannot think of a logic to use here? I thought about dividing [arryData count]/4 but that will give me fractions
}
圖片勝過千言萬語。
這真的很不錯:)。 – danypata
哇,謝謝。真正驚訝於你的數學方程! :) –