UIButton没有出现在iPhone 5S上 [英] UIButton doesn't appear on iPhone 5S

查看:100
本文介绍了UIButton没有出现在iPhone 5S上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iOS开发和开发有点新意。

I'm kind of new to iOS development and development in general.

我一直致力于保持应用程序的时间/记录,我遇到了一个奇怪的问题问题。在我的一个视图控制器上,我有一个UITableView,每个单元格都是一个通向不同视图控制器的按钮。在第一个单元格上,用户应该能够推送UIButton来运行开始计算时间的方法。当您运行该方法时,它会激活用户可以按下以停止计时的第二个UIButton。正在进行此操作时,单元格右侧的UILabel显示已用时间。

I've been working on a time/record keeping app and I ran into a weird problem. On one of my view controllers I have a UITableView with each cell being a button that leads to a different view controller. On the first cell the user is supposed to be able to push a UIButton to run a method that starts counting time. When you run that method it activates a second UIButton that the user can push to stop counting time. While this is going on a UILabel on the right hand side of the cell shows the elapsed time.

到目前为止,它一直运行良好,直到几天前。我下载并开始使用Xcode 5.1 beta 5并开始使用其中的应用程序。现在UIButtons没有出现在我的iPhone 5S或任何使用iPhone 5S的测试人员身上。它适用于iPhone模拟器和真正的非5S iPhone,包括iPad。

It has worked fine so far until a few days ago. I downloaded and started using Xcode 5.1 beta 5 and started working on the app in it. Now the UIButtons don't appear on my iPhone 5S or any of my testers that use iPhone 5S. It works on the iPhone Simulator and on real non-5S iPhones including iPad.

我想也许这是一个64位的问题,我查看了我的代码和找不到任何无法在64位设备上运行的东西。但是我看了一个Apple Developer Video,它说64位设备上的32位应用程序只会加载32位iOS库并运行它们。我还没有在我的应用程序上启用ARM-64,因为到目前为止我在任何设备上都没有遇到任何问题。测试版5中的iOS 7.1 SDK是否有变化需要在64位设备上以不同方式调用tableview或UIButton?我甚至尝试使用64位模拟器,它也能正常工作。

I thought maybe it was a 64-bit problem and I've looked around my code and can't find anything that wouldn't work on 64-bit devices. But I watched an Apple Developer Video that says that 32-bit apps on 64-bit devices will simply load the 32-bit iOS libraries and run them like that. I haven't enabled ARM-64 on my app yet, since so far I haven't had any problems with it on any device. Has there been a change in the iOS 7.1 SDK in beta 5 that requires tableviews or UIButtons to be called differently on 64-bit devices? I even tried it with a 64-bit simulator and it works fine on it too.

我把相关代码放在下面。我是开发中的新手,非常感谢任何帮助。

I put the relevant code below. I'm a newbie at development and would appreciate any help.

//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;

感谢您的帮助。

推荐答案

我找到了问题的解决方案。我更改了头文件中的属性,如下所示:

I found a solution to the problem. I changed the properties in the header file like this:

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

我不知道为什么当他们工作正常时我需要让他们坚强弱之前仍然在模拟器上工作。我只能猜测iOS 7.1的Beta 5中发生了一些变化 - 我之前使用的是Beta 3。但是一旦我更改了属性,我就可以再次看到测试iPhone 5S设备上的按钮。

I don't know why I would need to make them "Strong" when they worked fine as "Weak" before and still worked on the simulator. I can only guess that something has changed in Beta 5 of iOS 7.1 - I was previously building with Beta 3. But as soon as I changed the properties I could once again see the buttons on the test iPhone 5S devices.

这篇关于UIButton没有出现在iPhone 5S上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆