Adding a header view to a UIWebView similar to Safari and Articles

前端 未结 7 1857
耶瑟儿~
耶瑟儿~ 2020-12-07 19:17

I\'d like to add a header view to an UIWebView similar to the address/search bar in MobileSafari and the excellent Articles.app by Sophia Teutschler. More preci

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 20:07

    Enormego published some sample code to make the pull-to-refresh thing happen:

    https://github.com/enormego/EGOTableViewPullRefresh

    It's really not so complicated. You can get a Safari/Articles-style header bar in your table view simply by creating your header bar and just adding it to your UITableView as a subview. I'm doing exactly that on the app I'm working on now:

    GBSpendingMeter *meterView = [[[GBSpendingMeter alloc] initWithFrame:CGRectMake(0,0,320,44)] autorelease];
    
    // The meterView will appear pinned to the top of the table, similar to a headerView
    [self.tableView addSubview:meterView];
    

    The tricky part is observing the scroll events on the table (FYI, UITableView is a subclass of UIScrollView so all the same notifications/callbacks should work), but the sample code I linked to has a good example of how that works.

提交回复
热议问题