簡體   English   中英

將UIView(從情節提要中)修復到UITableView的頂部

[英]Fix a UIView(from storyboard) to the top of a UITableView

我已將一個故事板中的UIView附加到UITableView的頂部,並將其鏈接為IBOutlet的代碼,我希望將其固定在tableView的頂部。 我嘗試了幾種方法:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    headView.center = CGPointMake(headView.center.x + scrollView.contentOffset.x, headView.center.y + scrollView.center.y);
    [scrollView bringSubviewToFront:headView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGRect newFrame = headView.frame;
    newFrame.origin.y = 0;

    [headView setFrame:newFrame];
}

以及我在網站上找到的其他方法,但對我沒有用,我很headView ,因為我headView從情節headView連接headView的。
我該怎么做? 非常感謝!

聽起來您有一個UITableViewController並將視圖添加到表視圖標題視圖中,因此它隨表一起滾動。

如果是這種情況,請嘗試將主視圖控制器更改為UIViewController並在其中添加視圖和tableview。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM