iphone - 当 TableView 滚动比值更改时
<p><p>我创建了一个表格 View 来显示数组中的数据。但是现在当我滚动表格 View 时,我的数据会发生 Not Acceptable 变化。 </p>
<p>那么如何防止表格 View 在每次滚动时刷新并在创建表格 View 时第一次设置所有数据。</p>
<p>这是我的代码:</p>
<pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
ExampleAppDataObject* theDataObject = ; // Return the number of sections.
return theDataObject.vendorTableAry.count;//this is return value of array and it will be more than 2 which help to create section
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 4; // i want only 4 row in each section
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ExampleAppDataObject* theDataObject = ;
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell * cell = [tableView
dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
if(cell == nil) {
cell = [
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier];
/*cell = [[
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:SimpleTableIdentifier] autorelease];
*/
if (indexPath.row==0) {
UILabel * vendorLbl = [ initWithFrame:CGRectMake(10, 2, 60, 39)];
[ setCornerRadius:5.0f];
//];
vendorLbl.backgroundColor = ;
;
;
UILabel * columnLbl = [ initWithFrame:CGRectMake(80, 2, 10, 39)];
columnLbl.backgroundColor = ;
;
;
UILabel * vendorValueLbl = [ initWithFrame:CGRectMake(98, 2, 195, 39)];
[ setCornerRadius:5.0f];
//];
vendorValueLbl.backgroundColor = ;
];
;
}
if (indexPath.row==1) {
UILabel * vendorLbl = [ initWithFrame:CGRectMake(10, 2, 60, 39)];
[ setCornerRadius:5.0f];
//];
vendorLbl.backgroundColor = ;
;
;
UILabel * columnLbl = [ initWithFrame:CGRectMake(80, 2, 10, 39)];
columnLbl.backgroundColor = ;
;
;
UILabel * vendorValueLbl = [ initWithFrame:CGRectMake(98, 2, 195, 39)];
[ setCornerRadius:5.0f];
//];
vendorValueLbl.backgroundColor = ;
];
;
}
if (indexPath.row==2) {
UILabel * vendorLbl = [ initWithFrame:CGRectMake(10, 2, 60, 39)];
[ setCornerRadius:5.0f];
//];
vendorLbl.backgroundColor = ;
;
;
UILabel * columnLbl = [ initWithFrame:CGRectMake(80, 2, 10, 39)];
columnLbl.backgroundColor = ;
;
;
UILabel * vendorValueLbl = [ initWithFrame:CGRectMake(98, 2, 195, 39)];
[ setCornerRadius:5.0f];
//];
vendorValueLbl.backgroundColor = ;
];
;
}
if (indexPath.row==3) {
UILabel * vendorLbl = [ initWithFrame:CGRectMake(10, 2, 60, 39)];
[ setCornerRadius:5.0f];
//];
vendorLbl.backgroundColor = ;
;
;
UILabel * columnLbl = [ initWithFrame:CGRectMake(80, 2, 10, 39)];
columnLbl.backgroundColor = ;
;
;
UILabel * vendorValueLbl = [ initWithFrame:CGRectMake(98, 2, 195, 39)];
[ setCornerRadius:5.0f];
//];
vendorValueLbl.backgroundColor = ;
];
;
}
}
return cell;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>只需将 <code>dequeueReusableCellWithIdentifier</code> 设置为 <code>nil</code>,如下所示..</p>
<pre><code>UITableViewCell * cell = ;
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 当 TableView 滚动比值更改时,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/14353280/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/14353280/
</a>
</p>
页:
[1]