我正在尝试实现类似于Apple的日历应用程序设置开始时间和结束时间视图的视图.我认为看起来很棒,但我遇到了两个问题.首先,我想自动选择第一行.我有点使用这个:
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
[dateTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];
Run Code Online (Sandbox Code Playgroud)
但是,动画显示,在视图加载时可视地选择rown,我希望在视图加载时已选择它.
第二个也是更重要的问题是,当我在选择器更新后重新加载数据时,我会丢失选择,而我的任务根本不起作用.
现在我知道这是reloadData的默认操作,我正在寻找一种替代方法来实现我的目标,或者也许我可以如何扩充reloadData以不取消选择当前选择.
我的任务包括在下面:
-(IBAction)dateChanged
{
NSIndexPath *index = self.dateTableView.indexPathForSelectedRow;
if(index == 0)
{
if (self.date2 == plusOne ) {
self.date = [datePicker date];
plusOne = [self.date dateByAddingTimeInterval:60*60];
self.date2 = plusOne;
}
else
{
self.date = [datePicker date];
}
}
else{
self.date2 = [datePicker date];
}
[dateTableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
注意:plusOne是一个变量,最初表示距当前时间一小时.
提前致谢!
所以我运行一个sql查询,我管道导出-csv,唯一的问题是所有的值都用引号封装,包括整数,这是不可能重新导入SQL作为整数,任何想法为什么?
我想在调用ViewWillAppear方法时重新加载我的表视图的一部分,我已经实现了这样:
- (void)viewWillAppear:(BOOL)animated {
NSIndexPath* rowToReload = [NSIndexPath indexPathForRow:0 inSection:1];
reloadRows = [NSArray arrayWithObjects:rowToReload, nil];
[self.tableView reloadRowsAtIndexPaths:reloadRows withRowAnimation:UITableViewRowAnimationNone];
}
Run Code Online (Sandbox Code Playgroud)
以下是rowforsection方法,指示每个tableview部分中应显示哪些内容:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"fadk");
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"PINGAS"];
[self.tableView setAlwaysBounceVertical:YES];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:@"PINGAS"] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
// if ([indexPath section] == 0) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 3, 300, 41)];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 0, 300, 120)];
UIView *paddingView = [[[UIView alloc] …Run Code Online (Sandbox Code Playgroud)