我的目的是当用户点击view1(进入view2)按钮时,我会将UITableView刚刚签入的所有选定单元格发送view1到view2.所以在将表格传递到下一个视图之前,我想测试一下我是否在正确的轨道上,但似乎没有.这是我的代码:
-(IBAction)goToView2{
//get all section selectioned items into an array
themesChosed=[tView indexPathsForSelectedRows];//tView is the outlet of my UITableView and themesChosed is an NSArray declared in the .h file
for (int i=0; i<=[themesChosed count]; i++) {
NSLog(@"%i",[[themesChosed objectAtIndex:i]integerValue]);
}
}
Run Code Online (Sandbox Code Playgroud)
这总是给我一个0.
2012-01-13 15:52:06.472 MyApp[876:11603] 0
Run Code Online (Sandbox Code Playgroud)
虽然我在桌子上选了几个项目.
对象themesChosed是NSIndexPath对象.您将要访问row和section属性,如下所示:
-(IBAction)goToView2{
//get all section selectioned items into an array
themesChosed=[tView indexPathsForSelectedRows];//tView is the outlet of my UITableView and themesChosed is an NSArray declared in the .h file
for (int i=0; i<=[themesChosed count]; i++) {
NSIndexPath *thisPath = [themesChosed objectAtIndex:i];
NSLog(@"row = %i, section = %i", thisPath.row, thisPath.section);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2135 次 |
| 最近记录: |