UIButton不会出现在iPhone 5S上

总的来说,我对iOS的开发和开发很陌生。

我一直在做一个时间/logging的应用程序,我遇到了一个奇怪的问题。 在我的一个视图控制器中,我有一个UITableView,每个单元都是一个导致不同视图控制器的button。 在第一个单元格用户应该能够推UIButton运行开始计时的方法。 当你运行这个方法时,它会激活第二个UIButton,用户可以通过它来停止计时。 在单元右侧的UILabel显示已经过的时间。

到目前为止,它一直工作得很好。 我下载并开始使用Xcode 5.1 beta 5,并开始在其中的应用程序。 现在,UIButtons不会出现在我的iPhone 5S或任何使用iPhone 5S的testing仪上。 它适用于iPhone模拟器和真正的非5S iPhone,包括iPad。

我想也许这是一个64位的问题,我已经环顾了我的代码,并找不到任何不能在64位设备上工作的东西。 但我看了一个苹果开发者video,说64位设备上的32位应用程序将简单地加载32位iOS库,并像这样运行它们。 我还没有在我的应用上启用ARM-64,因为到目前为止,我在任何设备上都没有任何问题。 testing版5中的iOS 7.1 SDK是否发生了变化,需要在64位设备上以不同的方式调用tableviews或UIButtons? 我甚至用一个64位的模拟器尝试过,它也能正常工作。

我把下面的相关代码。 我是一个新手在发展,将不胜感激任何帮助。

//Set Button Properties self.startTimeButton.frame = CGRectMake(0, 0, 100, 39); self.startTimeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [self.startTimeButton setTitle:@"Start Time" forState:UIControlStateNormal]; self.startTimeButton.backgroundColor = [UIColor greenColor]; [self.startTimeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [self.startTimeButton setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled]; [self.startTimeButton addTarget:self action:@selector(startCountingTime) forControlEvents:UIControlEventTouchUpInside]; //Set Button 2 Properties self.stopTimerOut = [UIButton buttonWithType:UIButtonTypeRoundedRect]; self.stopTimerOut.frame = CGRectMake(100, 0, 100, 39); [self.stopTimerOut setTitle:@"Stop Time" forState:UIControlStateNormal]; self.stopTimerOut.backgroundColor = [UIColor redColor]; [self.stopTimerOut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [self.stopTimerOut addTarget:self action:@selector(stopCountingTime) forControlEvents:UIControlEventTouchUpInside]; //Set Timer Label self.timerDisplayLabel = [[UILabel alloc] initWithFrame:CGRectMake(250, 0, 60, 40)]; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; // First Section - Time Section if (indexPath.section == 0) { if (indexPath.row == 0) { [cell addSubview:self.startTimeButton]; [cell addSubview:self.stopTimerOut]; [cell addSubview:self.timerDisplayLabel]; [cell addSubview:self.timerActivityDiscloser]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.row == 1) { cell.textLabel.text = @"Manually Enter Time"; } if (indexPath.row == 2) { cell.textLabel.text = @"View Time for Month"; } } 

这是我的头文件

 @property (weak, nonatomic) UIButton *startTimeButton; @property (weak, nonatomic) UIButton *stopTimerOut; @property (strong, nonatomic) UILabel *timerDisplayLabel; 

感谢您的帮助。

我find了解决问题的办法。 我改变了头文件中的属性,如下所示:

 @property (strong, nonatomic) UIButton *startTimeButton; @property (strong, nonatomic) UIButton *stopTimerOut; @property (strong, nonatomic) UILabel *timerDisplayLabel; 

我不知道为什么我以前需要使它们变得“强壮”,并且仍然在模拟器上工作。 我只能猜测,在iOS 7.1的Beta 5中发生了一些变化 – 我以前是使用Beta 3构build的。但只要我改变了属性,我就可以再次看到testingiPhone 5S设备上的button。