ios - UITableViewCells 未出现在 iPhone 5S 上的 iOS 7.1.2 中
<p><p>据我所知,我有很多问题只出现在 iOS 7.1.2 中;虽然我不确定它是否出现在早期版本中。在 iOS 7 上,我相信它很好,并且在模拟器上。</p>
<p>编辑**进一步的规范** </p>
<p>在 iOS 7.1.2 上,它适用于 iPhone 5,但不适用于 iPhone 5S</p>
<p>当我在设备上运行时,而不是在模拟器中。第一个单元格出现,但后续单元格不出现。登录 dequeue 方法显示单元已实例化并已出列。此外,除了在单元格中滚动之外,第一个单元格对 UI 完全没有响应。当我将单元格向上拖动到顶部时,它会出现直到到达表格 View 的顶部,然后完全消失。当我向下拖动单元格时,一切正常。 </p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if(indexPath.row==0)
{
;
HeaderCell *headerCell = (HeaderCell *);
//set up the labels to be loaded from restaurant
headerCell.restaurantName.text=self.restaurant.name;
headerCell.restaurantType.text=self.restaurant.placeType;
headerCell.restaurantDetails.text=;
headerCell.priceRating.text = ;
headerCell.address.text=self.restaurant.address;
headerCell.cityStateZip.text=;
headerCell.phoneNumber.text=;
headerCell.description.text=self.restaurant.restaurantDescription;
//set up the top most image from the header property of the restaurant
if(==YES)
{
headerCell.restaurantHeader.image=self.restaurant.header;
NSLog(@"Apparently the image loaded");
}else
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ // 1
NSData *data = ];
UIImage *img = [ initWithData:data];
dispatch_async(dispatch_get_main_queue(), ^(void) {
self.restaurant.header=img;
self.restaurant.isHeaderLoaded=YES;
headerCell.restaurantHeader.image=img;
});
});
}
//load the correct badge for wireless or not
//as well as the correct use woblet now button
UIImage* image;
if(self.restaurant.isSitDown)
{
image = ;
forState:UIControlStateNormal];
}
else
{
forState:UIControlStateNormal];
image = ;
}
headerCell.isSitdownBadge.image=image;
//set up the map
animated:YES];
//set a pin on the map
MKPointAnnotation *annotation = [ init];
];
;
//zoom that motherfucker in
;
//set up the points circle
UIImageView *view = [ init];
view.frame=CGRectMake(0, 0, headerCell.pointsImage.frame.size.height, headerCell.pointsImage.frame.size.height);
int percent = %[[(Reward *)-1] pointsRequired] intValue];
percent = 100*percent/[[(Reward *)-1] pointsRequired] intValue];
] andTintColor:];
//set the blue swirl
;
//set the number of points until the next reward
headerCell.pointsUntilNextReward.text = ];
//assign our return cell to header cell
return headerCell;
}
else
{
//instantiate a RewardCell to reassign to cell at a later point
RewardCell *rewardCell;
//pull the appropriate reward from the restaurant
Reward *reward = [ objectAtIndex:indexPath.row-1];
if(<=)
{
//if you have more points that the points required for a given reward dequeue with the identifier reward cell on in order to use the appropriate UI.
rewardCell = (RewardCell *);
}
else
{
//otherwise you need to use the UI for when you don't have enough points.
rewardCell = (RewardCell *);
}
//number of points you need to use a given reward need to be set
rewardCell.numberOfPointsRequired.text = ;
//the description needs to be set on the cell
rewardCell.rewardDescription.text=reward.rewardDescription;
//the cell needs to be assigned to our rewardCell that we instantiated and dequeued at the beginning on the if
return rewardCell;
}
return cell;
}
</code></pre>
<p>编辑:
对不起,在我的挫折中,我误读了一些东西。它适用于其中一部带有 7.1.2 的手机,而另一部带有 7.1.2 的手机则不适用。我要看看差异。</p>
<p>编辑 2:
我发现了问题,它在一段我没有包含的代码中:</p>
<pre><code>-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
return 436;
return 55;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这里的问题在于我声明的方法具有与 64 位架构冲突的不正确返回类型:</p>
<pre><code>-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
</code></pre>
<p>这会返回一个 float 。一切看起来都很老套,但在 64 位架构中这会失败,因为返回类型实际上是 CGFloat,它是一个可以返回 double 或浮点的宏。因此,在非 64 位架构中,从浮点到 CGFloat 的转换很好,因为在 32 位架构中 CGFloat 是浮点。在 64 位架构中,CGFloat 是一个 double;然而。 </p>
<p>更改此位修复了之前出现的神秘错误。</p>
<pre><code>-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
</code></pre></p>
<p style="font-size: 20px;">关于ios - UITableViewCells 未出现在 iPhone 5S 上的 iOS 7.1.2 中,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/25792393/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/25792393/
</a>
</p>
页:
[1]