Home Database Mysql Tutorial 关于下拉更新框架 EGORefreshTableHeaderView在Xcode4.2中, ARC

关于下拉更新框架 EGORefreshTableHeaderView在Xcode4.2中, ARC

Jun 07, 2016 pm 03:37 PM
drop down about renew frame

关于如何在页面中使用EGORefreshTableHeaderView的文章网上一大把, 抄来抄去的, 但也都没什么大问题. 只是在XCode4.2的ARC环境中使用的时候, 错误一把. 借此机会, 完整的记录一下如何排除错误, 及使用的方法. 首先第一步当然是下载这个下拉更新的框架了. htt

关于如何在页面中使用EGORefreshTableHeaderView的文章网上一大把, 抄来抄去的, 但也都没什么大问题.  只是在XCode4.2的ARC环境中使用的时候, 错误一把. 借此机会, 完整的记录一下如何排除错误, 及使用的方法.

首先第一步当然是下载这个下拉更新的框架了.  https://github.com/enormego/EGOTableViewPullRefresh/downloads


下载之后解包, 然后将 

EGORefreshTableHeaderDelegate.h

EGORefreshTableHeaderDelegate.m

这两个文件, 以及项目中的图片文件都复制到你的项目文件内, 这时候, 如果你启用了ARC, 应该会报一片错误, 让我们来具体看一下. 


启用了ARC之后, 就不允许手动的release了, 因此, [view release], [lable release] 还有 autorelease这样的代码都需要删除掉.

在EGORefreshTableHeaderDelegate.m的这个文件中,   @synthesize delegate=_delegate;  会报错,  "Existing ivar 'delegate' for assign property 'delegate' must be... 

解决办法是需要将EGORefreshTableHeaderDelegate.h文件中的 assign 换为retain

//@property(nonatomic,assign) id <egorefreshtableheaderdelegate> delegate;   //删除掉. 换为下面的
@property(nonatomic,retain)id <egorefreshtableheaderdelegate> delegate;</egorefreshtableheaderdelegate></egorefreshtableheaderdelegate>
Copy after login

这样代码就会通过编译了~ 这样就需要将EGORefreshTableHeaderView与我们的tableview整合了, 然后按照Demo的方法, 

添加EGORefreshTableHeaderDelegate的接口, 

定义_reloading, 和EGORefreshHeaderView

声明reloadTableViewDataSource和doneLoadingTableView这两个函数

#import <uikit>
#import "EGORefreshTableHeaderView.h"

@interface FMFutureMessage : UIViewController<uitableviewdelegate uitableviewdatasource>
{
    BOOL _reloading;
    EGORefreshTableHeaderView *_refreshHeaderView;
}

@property(strong, nonatomic) IBOutlet UITableView *tbView;

-(void)reloadTableViewDataSource;
-(void)doneLoadingTableViewData; 
@end</uitableviewdelegate></uikit>
Copy after login

接下来, 我们需要将xib文件中的TableViewController与这里定义的tbView建立关联, 因为我忘记了指定tbView与XIB中的TabViewController, 导致了刷新箭头怎么样也显示不出来, 所以一定不要忘记啊~~~~
现在我们处理一下.m文件

处理m文件, 建立关联.和响应事件.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    if(_refreshHeaderView == nil)
    {
        EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tbView.bounds.size.height, self.view.frame.size.width, self.tbView.bounds.size.height)];
 
        view.delegate = self;
        [self.tbView addSubview:view];
        _refreshHeaderView = view;
    }
    [_refreshHeaderView refreshLastUpdatedDate];
}
Copy after login


响应事件, 事件的响应代码就简单的多了, 按照DEMO的方法, 把接口的函数都声明了就OK了.
 
-(void)reloadTableViewDataSource
{
    NSLog(@"==开始加载数据");
    [self.tbView reloadData];
    _reloading = YES;
     
}
- (void)doneLoadingTableViewData{  
    
     NSLog(@"===加载完数据"); 
    //  model should call this when its done loading  
       _reloading = NO;  
    [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tbView];  
 
 
}  
#pragma mark – 
#pragma mark UIScrollViewDelegate Methods 
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{  
    
    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];  
    
}  

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{  
    
    [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];  
    
}
 
#pragma mark – 
#pragma mark EGORefreshTableHeaderDelegate Methods 
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{  
    
    [self reloadTableViewDataSource];  
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];  
  
      
    
}  
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{  
    
    return _reloading; // should return if data source model is reloading  
    
}  
- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{  
    
    return [NSDate date]; // should return date data source was last changed  
    
}
Copy after login

最后, 如果是开发中文应用程序, 不要忘记进入EGORefreshTableHeaderView.m中, 将提示的英文换成中文. 


好了, 完成~~~

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Windows cannot access the specified device, path, or file Windows cannot access the specified device, path, or file Jun 18, 2024 pm 04:49 PM

A friend's computer has such a fault. When opening "This PC" and the C drive file, it will prompt "Explorer.EXE Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the project." Including folders, files, This computer, Recycle Bin, etc., double-clicking will pop up such a window, and right-clicking to open it is normal. This is caused by a system update. If you also encounter this situation, the editor below will teach you how to solve it. 1. Open the registry editor Win+R and enter regedit, or right-click the start menu to run and enter regedit; 2. Locate the registry "Computer\HKEY_CLASSES_ROOT\PackagedCom\ClassInd"

Windows permanently pauses updates, Windows turns off automatic updates Windows permanently pauses updates, Windows turns off automatic updates Jun 18, 2024 pm 07:04 PM

Windows updates may cause some of the following problems: 1. Compatibility issues: Some applications, drivers, or hardware devices may be incompatible with new Windows updates, causing them to not work properly or crash. 2. Performance issues: Sometimes, Windows updates may cause the system to become slower or experience performance degradation. This may be due to new features or improvements requiring more resources to run. 3. System stability issues: Some users reported that after installing Windows updates, the system may experience unexpected crashes or blue screen errors. 4. Data loss: In rare cases, Windows updates may cause data loss or file corruption. This is why before making any important updates, back up your

How to evaluate the cost-effectiveness of commercial support for Java frameworks How to evaluate the cost-effectiveness of commercial support for Java frameworks Jun 05, 2024 pm 05:25 PM

Evaluating the cost/performance of commercial support for a Java framework involves the following steps: Determine the required level of assurance and service level agreement (SLA) guarantees. The experience and expertise of the research support team. Consider additional services such as upgrades, troubleshooting, and performance optimization. Weigh business support costs against risk mitigation and increased efficiency.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

How to choose the best golang framework for different application scenarios How to choose the best golang framework for different application scenarios Jun 05, 2024 pm 04:05 PM

Choose the best Go framework based on application scenarios: consider application type, language features, performance requirements, and ecosystem. Common Go frameworks: Gin (Web application), Echo (Web service), Fiber (high throughput), gorm (ORM), fasthttp (speed). Practical case: building REST API (Fiber) and interacting with the database (gorm). Choose a framework: choose fasthttp for key performance, Gin/Echo for flexible web applications, and gorm for database interaction.

How to update Google Chrome How to update Google Chrome Jul 20, 2024 am 12:26 AM

Browser updates and upgrades are not uncommon, and some of the problems we encounter online may be caused by the system not being updated in time. Stable updates can ensure normal use of the browser, and we can better use the functions inside and maximize the performance of the browser. So how to update Google Chrome? This site brings you how to update Google Chrome to solve everyone's difficulties. The first step to update Google Chrome: Open the Chrome browser and click the [three dots] in the upper right corner. (As shown in the picture) Step 2: Click [Settings] in the menu drop-down to enter. (As shown in the picture) Step 3: Find [About Chrome] on the right and click to enter. (As shown in the picture) Step 4: Chrome browser will automatically check and install updates. (As shown in the picture

Detailed practical explanation of golang framework development: Questions and Answers Detailed practical explanation of golang framework development: Questions and Answers Jun 06, 2024 am 10:57 AM

In Go framework development, common challenges and their solutions are: Error handling: Use the errors package for management, and use middleware to centrally handle errors. Authentication and authorization: Integrate third-party libraries and create custom middleware to check credentials. Concurrency processing: Use goroutines, mutexes, and channels to control resource access. Unit testing: Use gotest packages, mocks, and stubs for isolation, and code coverage tools to ensure sufficiency. Deployment and monitoring: Use Docker containers to package deployments, set up data backups, and track performance and errors with logging and monitoring tools.

See all articles