我對iOS開發和開發有點新。UIButton沒有出現在iPhone 5S上
我一直在工作時間/記錄保存應用程序,我遇到了一個奇怪的問題。在我的一個視圖控制器中,我有一個UITableView,每個單元都是一個導致不同視圖控制器的按鈕。在第一個單元格中,用戶應該能夠推送UIButton來運行開始計時的方法。當你運行該方法時,它會激活第二個UIButton,用戶可以通過它來停止計時。在這種情況下,單元格右側的UILabel顯示已用時間。
它一直很好,到目前爲止,直到前幾天。我下載並開始使用Xcode 5.1 beta 5,並開始在其中開發應用程序。現在,UIButtons不會出現在我的iPhone 5S或任何使用iPhone 5S的測試儀上。它適用於iPhone模擬器以及真正的非5S iPhone,包括iPad。
我想也許這是一個64位的問題,我已經在我的代碼看,並不能找到任何東西,不會在64位的設備。但是我觀看了Apple開發者視頻,其中說,64位設備上的32位應用程序將簡單加載32位iOS庫並像那樣運行它們。我的應用尚未啓用ARM-64,因爲到目前爲止,我在任何設備上都沒有遇到任何問題。測試版5中的iOS 7.1 SDK是否發生了變化,需要在64位設備上以不同的方式調用tableviews或UIButton?我甚至用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;
謝謝您的幫助。
iOS beta是棘手的。嘗試重新構建應用程序作爲一個新項目,並用該測試版將您的工作複製到該新項目中,然後查看該項目是否有效,否則會引發警告或異常。與貝塔斯一起工作,我瞭解到,並非所有的扭曲都能解決。畢竟它是一個測試.. :) –
我遇到了問題,由於這個確切的問題。這在Xcode 5.1和iPhone 5S的GA版本中仍然存在。 –