/rewrite The Get method of forwarding Weibo view lazy loading, implementation of the forward micro-blog View multiplexing Lazy loading is when the program runs, not all of a sudden load a lot of controls, but later need to re-use Lazy loading is the form of rewriting the Get method while the inside is judged followed by if (Obj==nil), this form The forwarded Weibo view here also takes into account the view reuse problem. -(Lyweiboview *) reweiboview{ If inside the judgment to be written _reweiboview, if write Self.reweiboview, it belongs to _eweiboview get method, get method inside with the property of the Get method value judgment will enter the dead loop, So when you rewrite the Get method here, be sure to use _reweiboview to determine if there is Note: _reweiboview = = Nil, the whole is a Get method, Self.reweiboview =, belongs to the Set method; if (_reweiboview = = nil) { Now create a, drop OH use time to assign value when the Fram _reweiboview = [[Lyweiboview Alloc]initwithframe:cgrectzero]; [Self addsubview:_reweiboview]; Self.reWeiboView.backgroundColor = Lygraycolor; } return _reweiboview; } ----------------------Functional Partitioning----------------------------- [Lysinautils requestweiboswithparams:params callback:^ (id obj) { The requested back data is a large array Self.weibos = obj; This block is called by the Lysinautils method, block with other objects in the method will not error warning, if this block method is called with TableView, will be error, when the error is in the block method outside with "__block" decoration [TableView Reloaddata]; // }]; ----------------------Functional Partitioning----------------------------- /* The right side of the equal sign is always the FET method, and the following self.params belongs to the call get method, Self.params.count belongs to the set method, and the nearest attribute to the left of an equals sign is called the Set method [Email protected] (3); */ __block typeof (self) weakself = self; __block Lyhomeviewcontroller *weakself = self; __block here to remember, when the block in the access attribute, there may be an error, directly remember to add __block decoration on the outside. Adding pull-up loading and drop-down refreshes can cause memory count +1 when accessing variables in the block, which may cause the object to be released __weak and __block can make the variable memory count not add 1 when used in block Add a drop-down refresh Event [TableView addpulltorefreshwithactionhandler:^{ If there is data at the time of the refresh, determine if there is currently any Weibo data. if (self.weibos.count>0) { Find the first [0] of the Weibo data array is the latest user-issued Weibo ID Lyweibo *weibo = self.weibos[0]; Get updates on Weibo than your latest Weibo blog self.params.since_id = Weibo.wid; } [Lysinautils requestWeibosWithParams:self.params callback:^ (id obj) { When added below, the system does not know what obj is and catches it in advance with an array. Nsarray *newweibos = obj; Inserts the requested new data into the front of the array [Self.weibos insertobjects:obj atindexes:[nsindexsetindexsetwithindexesinrange:nsmakerange (0, NewWeibos.count)]; [Self.tableview Reloaddata]; End drop-down refresh animation [Self.tableView.pullToRefreshView stopanimating]; }]; }]; Adding a pull-up load event [TableView addinfinitescrollingwithactionhandler:^{ If it's a pull-up load, you can't set since_id or you can't get the data. If the since_idyou parameter is set, the system will request the latest data instead of loading the previous data. self.params.since_id = nil; Set Request pages Self.params.page = @ (self.params.page.intvalue+1); Pull-up loading [Lysinautils requestWeibosWithParams:self.params callback:^ (id obj) { Append the acquired microblog array to the data source array [Self.weibos Addobjectsfromarray:obj]; [Self.tableview Reloaddata]; End Pull-load animation [Self.tableView.infiniteScrollingView stopanimating]; }]; }]; Trigger drop-down refresh [Self.tableview Triggerpulltorefresh]; |