gpt4 book ai didi

ios - UITableViewCells 未出现在 iPhone 5S 上的 iOS 7.1.2 中

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:20:45 24 4
gpt4 key购买 nike

据我所知,我有很多问题只出现在 iOS 7.1.2 中;虽然我不确定它是否出现在早期版本中。在 iOS 7 上,我相信在模拟器上没问题。

编辑 **进一步规范 **

在 iOS 7.1.2 上,它适用于 iPhone 5 但不适用于 iPhone 5S

当我在设备上运行时,而不是在模拟器中。第一个单元格出现,但后续单元格不出现。登录 dequeue 方法显示单元格已实例化并已出队。此外,除了在单元格中滚动外,第一个单元格对 UI 完全无响应。当我将单元格向上拖动到顶部时,它会出现直到到达表格 View 的顶部,然后完全消失。当我向下拖动单元格时,一切正常。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if(indexPath.row==0)
{
[self.restaurant sortRewards];
HeaderCell *headerCell = (HeaderCell *)[tableView dequeueReusableCellWithIdentifier:@"HeaderCell" forIndexPath:indexPath];
//set up the labels to be loaded from restaurant
headerCell.restaurantName.text=self.restaurant.name;
headerCell.restaurantType.text=self.restaurant.placeType;
headerCell.restaurantDetails.text=[self.restaurant getFormattedDetails];
headerCell.priceRating.text = [self.restaurant getPriceRatingString];
headerCell.address.text=self.restaurant.address;
headerCell.cityStateZip.text=[self.restaurant getCityStateZipString];
headerCell.phoneNumber.text=[self.restaurant phoneNumber];
headerCell.description.text=self.restaurant.restaurantDescription;
//set up the top most image from the header property of the restaurant
if([self.restaurant isHeaderLoaded]==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 = [NSData dataWithContentsOfURL:[self.restaurant headerURL]];
UIImage *img = [[UIImage alloc] 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 = [UIImage imageNamed:@"ico_wireless-1"];
[headerCell.useWobletNow setBackgroundImage:[UIImage imageNamed:@"Use Woblet Button Wireless"] forState:UIControlStateNormal];
}
else
{
[headerCell.useWobletNow setBackgroundImage:[UIImage imageNamed:@"Use Woblet Button QR"] forState:UIControlStateNormal];
image = [UIImage imageNamed:@"ico_qr_code-1"];
}
headerCell.isSitdownBadge.image=image;
//set up the map
[headerCell.map setCenterCoordinate:[self.restaurant.location coordinate] animated:YES];
//set a pin on the map
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:[self.restaurant.location coordinate]];
[headerCell.map addAnnotation:annotation];
//zoom that motherfucker in
[self zoomMapViewToFitAnnotations:headerCell.map animated:NO];
//set up the points circle
UIImageView *view = [[UIImageView alloc] init];
view.frame=CGRectMake(0, 0, headerCell.pointsImage.frame.size.height, headerCell.pointsImage.frame.size.height);
int percent = [self.restaurant.numberOfPoints intValue]%[[(Reward *)[self.restaurant.rewards objectAtIndex:[self.restaurant.rewards count]-1] pointsRequired] intValue];
percent = 100*percent/[[(Reward *)[self.restaurant.rewards objectAtIndex:[self.restaurant.rewards count]-1] pointsRequired] intValue];
[view applyCircleWithPercentage:percent andText:[NSString stringWithFormat:@"%@",[self.restaurant.numberOfPoints stringValue]] andTintColor:[UIColor colorWithRed:5.0f/255.0f green:98.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
//set the blue swirl
[headerCell.pointsImage addSubview:view];
//set the number of points until the next reward

headerCell.pointsUntilNextReward.text = [NSString stringWithFormat:@"%d pts",[self.restaurant pointsUntilNextReward]];
//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 = [[self.restaurant rewards] objectAtIndex:indexPath.row-1];
if([reward.pointsRequired intValue]<=[self.restaurant.numberOfPoints intValue])
{
//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 *)[tableView dequeueReusableCellWithIdentifier:@"RewardCellOn" forIndexPath:indexPath];
}
else
{
//otherwise you need to use the UI for when you don't have enough points.
rewardCell = (RewardCell *)[tableView dequeueReusableCellWithIdentifier:@"RewardCellOff" forIndexPath:indexPath];
}
//number of points you need to use a given reward need to be set
rewardCell.numberOfPointsRequired.text = [NSString stringWithFormat:@"%@ pts",reward.pointsRequired];
//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;
}

编辑:对不起,在我的沮丧中,我误读了一些东西。它适用于其中一部 7.1.2 的手机,而另一部 7.1.2 的手机则不能。我要看看差异。

编辑 2:我发现了问题,它出在我没有包含的一段代码中:

-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
return 436;
return 55;
}

最佳答案

这里的问题在于我声明的方法有一个与 64 位架构冲突的不正确的返回类型:

-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

这将返回一个 float 。一切看起来都像 honkey dorey,但在 64 位架构中这失败了,因为返回类型实际上是 CGFloat,它是一个可以返回 double 或 float 的宏。因此,在非 64 位架构中,从 float 到 CGFloat 的转换很好,因为在 32 位架构中 CGFloat 是一个 float。在 64 位架构中,CGFloat 是一个 double ;然而。

更改此位可修复之前出现的神秘错误。

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

关于ios - UITableViewCells 未出现在 iPhone 5S 上的 iOS 7.1.2 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25792393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com