ios - 以编程方式创建的表格 View 的延迟称重传感器图像
<p><p>我正在以编程方式创建许多表格 View 。客户特别要求一个不是 UITableViewController 的布局。比如:</p>
<p> <img src="/image/fhxUw.png" alt="enter image description here"/> </p>
<p>表格 View 的数量以及每个表格中的项目数量各不相同。加载 View 时会立即创建所有表。我想为表格 View 中的单元格添加缩略图。我需要找到一种延迟加载缩略图的方法。我已经成功地在 UITableViewController 上实现了延迟加载。我之前的成功部分是因为我可以使用 调用来指示可以在缓存图像后显示单元格缩略图。我如何对以编程方式创建的 TableView 实现延迟加载?我最初的想法是在表格 View 中添加某种选择器,以便在为特定单元格缓存图像后更新单元格。我不确定这将如何工作,并希望得到任何帮助。 </p>
<p>以下是我用来以编程方式创建 TableView 的代码(我使用的是 ARC):</p>
<pre><code>@interface SyllabusSegmentedViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, weak)IBOutlet UIScrollView *SyllabusSegmentedSV;
</code></pre>
<p>--</p>
<pre><code>@implementation SyllabusSegmentedViewController
- (void) viewWillAppear:(BOOL)animated {
;
// Programmatic creation of the table views and titles for Table Views
;
}
-(void) ProgramaticCreationOfTableView:(id)sender {
for (numTableViews = 0; numTableViews < ; numTableViews ++) {
// Create Table View
UITableView *newTableView = [ init];
newTableView = ;
// Create UILabel that will act as Title for Each table view
UILabel *newLabel = [ initWithFrame:];
;
newLabel.backgroundColor = ;
newLabel.text = ;
newLabel.textAlignment = NSTextAlignmentCenter;
UIFont *font = ;
UIColor *color = ;
newLabel.font = font;
newLabel.textColor = color;
;
newTableView.backgroundColor = ;
newTableView.scrollEnabled = NO;
newTableView.frame = ();
newTableView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
newLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
;
;
}
}
-(UITableView *)createTableView:(id)sender {
UITableView *tableView = [ initWithFrame:[ applicationFrame] style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.accessibilityLabel = ;
return tableView;
}
-(CGRect)MakeHeaderLabelFrame:(int)workingTableNumber workingTableView:(UITableView *)newTableView {
int numberOfPreviousLevelsRows = 0;
for (int i = 0; i < workingTableNumber ; i ++) {
numberOfPreviousLevelsRows += [] count];
}
return CGRectMake(0, 75 + ((workingTableNumber * 80) + (numberOfPreviousLevelsRows *55)), self.view.bounds.size.width, 25);
}
-(CGRect)MakeTableViewFrame:(int)workingTableNumber workingTableView:(UITableView *)newTableView {
int numberOfPreviousLevelsRows = 0;
for (int i = 0; i < workingTableNumber ; i ++) {
numberOfPreviousLevelsRows += [] count];
}
return CGRectMake(0, 95 + ((workingTableNumber * 80) + (numberOfPreviousLevelsRows *55)), self.view.bounds.size.width, 65*);
}
</code></pre>
<p>我还实现了 UITableViewDelegate 的必要功能,例如 </p>
<pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>看看图书馆<a href="https://github.com/rs/SDWebImage" rel="noreferrer noopener nofollow">SDWebImage</a> </p>
<p>我想这就是你要找的。</p>
<p>但可能是您的方法的真正问题:我想实际上没有必要创建一个接一个地定位的多个 TableView - 在这种情况下,部分可能会做这件事。</p>
<p><strong>编辑</strong></p>
<p>TableViewDataSource 有名为 <code>-numberOfSectionsInTableView:</code> 的方法。</p>
<p>也可以通过实现<code>--tableView:heightForHeaderInSection:</code> 或<code>--tableView:heightForFooterInSection:</code> 来获得section之间必要的空间。</p>
<p>您应该在 SyllabusSegmentedViewController 中实现所有这些方法。</p></p>
<p style="font-size: 20px;">关于ios - 以编程方式创建的表格 View 的延迟称重传感器图像,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18083866/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18083866/
</a>
</p>
页:
[1]