- (void)viewDidLoad { [super viewDidLoad]; // 创建tableview [self setTableView]; [self setupRefresh]; } // 下拉刷新 - (void)setupRefresh { NSLog(@"setupRefresh -- 下拉刷新"); UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(refreshClick:) forControlEvents:UIControlEventValueChanged]; refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"正在刷新"]; //刷新图形时的颜色,即刷新的时候那个菊花的颜色 refreshControl.tintColor = [UIColor redColor]; [self.tableview addSubview:refreshControl]; [refreshControl beginRefreshing]; [self refreshClick:refreshControl]; } // 下拉刷新触发,在此获取数据 - (void)refreshClick:(UIRefreshControl *)refreshControl { NSLog(@"refreshClick: -- 刷新触发"); // 。。。// 此处添加刷新tableView数据的代码 // 查询数据库 self.dbCtrl=[[FMVC1 alloc]init]; self.datasource=[self.dbCtrl select_data]; [refreshControl endRefreshing]; [self.tableview reloadData];// 刷新tableView即可 }