小编gig*_*ari的帖子

iPhone加速度计到底测量的是什么?

UIAcceleration类苹果文档说,

"当设备背面静止放置在水平表面上时,每个加速事件都有大约以下值:
x:0
y:0
z:-1
"

现在,我很困惑!当你清楚地说"设备正在静止"时,加速度如何不为零?

UPDATE

从响应来看,我认为这应该被称为"力计"或"重力计",而不是加速度计!

iphone physics accelerometer ios

11
推荐指数
4
解决办法
6925
查看次数

如何从UIButton操作方法获取UITableViewCell对象?

我有一个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)

uibutton uitableview ios

2
推荐指数
1
解决办法
1万
查看次数

自定义设置器未在UIView中调用

我正在为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)

但是,二传手没有被叫到!有人可以告诉我为什么吗?

iphone objective-c getter-setter ios ios5

1
推荐指数
1
解决办法
1994
查看次数