"当设备背面静止放置在水平表面上时,每个加速事件都有大约以下值:
x:0
y:0
z:-1
"
现在,我很困惑!当你清楚地说"设备正在静止"时,加速度如何不为零?
从响应来看,我认为这应该被称为"力计"或"重力计",而不是加速度计!
我有一个UITableView,其中我添加了一个UIButton作为每个单元格的附件视图.请注意,我将按钮的标记设置为当前行以供将来使用.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cellButton = [UIButton buttonWithType:UIButtonTypeCustom];
cellButton.frame = CGRectMake(0, 0, 30, 30);
[cellButton setBackgroundImage:[UIImage imageNamed:@"cellButton.png"] forState:UIControlStateNormal];
[cellButton addTarget:self action:@selector(cellButtonAction:) forControlEvents:UIControlEventTouchUpInside];
cellButton.tag = indexPath.row; // <= Will use this in the next method
cell.accessoryView = cellButton;
}
//Load cell with row based data
return cell;
}
Run Code Online (Sandbox Code Playgroud)
现在当点击其中一个按钮时,我需要对单元格进行更改.所以我实现了cellButtonAction,我使用标签来取回单元格:
-(void)editCommentButtonAction:(id)sender
{
UIButton *button …Run Code Online (Sandbox Code Playgroud) 我正在为bool属性使用自定义设置器,因为当此值更改时,我需要做一些额外的工作。这是我的实现:
MyView.h
@interface MyView : UIView
@property (nonatomic) BOOL isSelected;
@end
Run Code Online (Sandbox Code Playgroud)
MyView.m
@implementation MyView
@synthesize isSelected;
-(void)setIsSelected:(BOOL)_isSelected
{
self.isSelected = _isSelected;
//Custom code that changes UI based on bool state
}
@end
Run Code Online (Sandbox Code Playgroud)
但是,二传手没有被叫到!有人可以告诉我为什么吗?