相关疑难解决方法(0)

UICollectionView上的UIRefreshControl仅在集合填充容器高度时才有效

我试图将添加UIRefreshControlUICollectionView,但问题是,刷新控制不会出现,除非集合视图填补了其父容器的高度.换句话说,除非集合视图足够长以至于需要滚动,否则无法向下拉以显示刷新控件视图.一旦集合超过其父容器的高度,它就会被拉下并显示刷新视图.

我已经UICollectionView在主视图内部设置了一个快速iOS项目,并在集合视图中添加了一个插座,以便我可以添加UIRefreshControlviewDidLoad.还有一个带有重用标识符的原型单元cCell

这是控制器中的所有代码,它很好地演示了这个问题.在此代码中,我将单元格的高度设置为100,这不足以填充显示,因此无法拉取视图并且不会显示刷新控件.将其设置为更高的值以填充显示,然后它可以工作.有任何想法吗?

@interface ViewController () <UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [self.collectionView addSubview:refreshControl];
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 1;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    return [collectionView dequeueReusableCellWithReuseIdentifier:@"cCell" forIndexPath:indexPath];
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(self.view.frame.size.width, 100);
}
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uirefreshcontrol

142
推荐指数
3
解决办法
6万
查看次数

我可以在UIScrollView中使用UIRefreshControl吗?

UIScrollView我的应用程序中已有大约5个已加载多个.xib文件.我们现在想用一个UIRefreshControl.它们构建为与UITableViewControllers一起使用(根据UIRefreshControl类引用).我不想重新做所有5个UIScrollView工作.我已经尝试过使用UIRefreshControlUIScrollView的,除了一些东西之外,它按预期工作.

  1. 在刷新图像变成加载器之后,UIScrollView跳跃大约10个像素,这只有在我非常小心地UIScrollview向下拖动时才会发生.

  2. 当我向下滚动并启动重装,然后让围棋UIScrollView,在UIScrollView那里我让它去住宿.重新加载完成后,UIScrollView跳转到顶部没有动画.

这是我的代码:

-(void)viewDidLoad
{
      UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
      [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
      [myScrollView addSubview:refreshControl];
}

-(void)handleRefresh:(UIRefreshControl *)refresh {
      // Reload my data
      [refresh endRefreshing];
}
Run Code Online (Sandbox Code Playgroud)

有什么方法可以节省一大堆时间并使用UIRefreshControla UIScrollView

谢谢!!!

iphone uiscrollview xamarin.ios ios uirefreshcontrol

73
推荐指数
5
解决办法
3万
查看次数

在ViewController中的UICollectionView中刷新以刷新

我在下面使用了以下代码 UICollectionViewController

override func viewDidLoad() {            

    self.collectionView!.alwaysBounceVertical = true
    let refresher = UIRefreshControl()
    refresher.addTarget(self, action: "refreshStream", forControlEvents: .ValueChanged)

    refreshControl = refresher
    collectionView!.addSubview(refreshControl!)
}

func refreshStream() {

    print("refresh")
    self.collectionView?.reloadData()

    refreshControl?.endRefreshing()

}
Run Code Online (Sandbox Code Playgroud)

现在我需要它与UICollectionView内部工作,UIViewController我用Google搜索了一个小时,但无法让它工作.我感谢任何帮助.

ios swift

31
推荐指数
4
解决办法
3万
查看次数

UIRefreshcontrol在拉下并握住时会紧张不安

我在tableviewcontroller中创建了一个UIRefreshcontrol,如下所示在viewdidload方法中:

    refresh = [UIRefreshControl.alloc init];
    refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
    [refresh addTarget:self action:@selector(refreshChatsTableView) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refresh;
Run Code Online (Sandbox Code Playgroud)

问题是,当我把它拉下来一段时间后,桌子会抖动,给人一种非常不愉快的UI体验.有人可以帮忙吗?仅在横向模式下才会遇到此问题.

这是我的代码:

-UIRefreshControl  *refresh;

    -(void)viewDidLoad{
        [super viewDidLoad];
         arr= [[NSArray    alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E",@"A",@"B",@"C",@"D",@"E", nil];

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


    -(void)refreshChatsTableView{
        [refresh endRefreshing];
    }

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        return 1;
    }

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
       return arr.count;
    }

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell =[[UITableViewCell alloc]init]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uirefreshcontrol pull-to-refresh ios7

11
推荐指数
2
解决办法
4142
查看次数

为什么UIRefreshControl跳?

我尝试将swift 1.2与UIRefreshControl一起使用,并且除了UI之外都可以正常工作。它在跳跃,我不知道为什么。这是我在做什么:

class ViewController: UIViewController {

     var refreshControl:UIRefreshControl!

    @IBOutlet weak var tableView: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()

        self.refreshControl = UIRefreshControl()
        self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
        self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
        self.tableView.addSubview(refreshControl)
    }

    func refresh(sender:AnyObject) {
        // Code to refresh table view
    }

}
Run Code Online (Sandbox Code Playgroud)

您可以从此处下载我的POC项目POC项目

当您拉下tableView时,突然跳下一点。有人知道为什么吗?

如果我使用UITableViewController,它可以正常工作,但我不想使用此UI对象。我想在UIViewController中使用一个简单的UITableView。

uitableview ios uirefreshcontrol swift

7
推荐指数
1
解决办法
5288
查看次数