gpt4 book ai didi

ios7 : Pull to refresh does not show up on simulator

转载 作者:行者123 更新时间:2023-12-01 16:41:19 25 4
gpt4 key购买 nike

我对 iOS 很陌生编程和一个类(class)项目,我试图实现“拉动刷新功能”

我试过了link ,并在我的 MoviesViewController 中实现相同

- (void)viewDidLoad
{
[super viewDidLoad];
self.moviesTableView.delegate = self;
self.moviesTableView.dataSource = self;

// pull to refresh
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self action:@selector(refreshView:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;

// progress bar
MBProgressHUD *HUD = [self getLoadingController];
[HUD showWhileExecuting:@selector(generateMovies) onTarget:self withObject:nil animated:YES];

self.moviesTableView.rowHeight = 100;
[self.moviesTableView registerNib:[UINib nibWithNibName:@"MovieViewCell" bundle:nil] forCellReuseIdentifier:@"MovieViewCell"];
}


-(void)refreshView:(UIRefreshControl *)refresh {
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Refreshing data..."];

// custom logic: get data from server
NSLog(@"refreshing view");


NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMM d, h:mm a"];
NSString *lastUpdated = [NSString stringWithFormat:@"Last updated on %@",[formatter stringFromDate:[NSDate date]]];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:lastUpdated];
[refresh endRefreshing];
}

但是当我在模拟器中运行它时,我在拉下电影表时看不到它。

这里可能是什么问题?

最佳答案

我认为您缺少将 HUD 添加到刷新控件中。根据您的 View 结构,您需要以下内容:

[self.refreshLoadingView addSubview:self.hud];

我们需要查看您的其余代码来调试问题,但这是我写的一个教程,解释了 iOS(包括 Swift)的自定义下拉刷新控件: http://www.jackrabbitmobile.com/design/ios-custom-pull-to-refresh-control/

关于ios7 : Pull to refresh does not show up on simulator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24102900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com