English 中文(简体)
详细披露图文的变化(Xcode 4.2)
原标题:Changing the Image for a detail disclosure button (Xcode 4.2)

我曾建议采用以下例行做法,改变表层视力单位的详细披露纽克文形象(见表G.ForRowAtIndexPath)。

if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

    UIButton *myAccessoryButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
    [myAccessoryButton setBackgroundColor:[UIColor clearColor]];
    [myAccessoryButton setImage:[UIImage imageNamed:@"ball"] forState:UIControlStateNormal];
    [cell setAccessoryView:myAccessoryButton];
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}

然而,活动<代码> 现在不再点击 but子。

是否有任何想法说明为什么?

问题回答

I ve +1 d Fry s response, but only to rec the Code in the other website to make SO more full: 答案是,你必须接受ButtonTapped.... 电话不会自动发出,因为要求进行详细内容的披露,因此,你必须按纽伦的目标行事。

从联系法到上文的例子,在设定后添加这一行文。 形象:

[myAccessoryButton addTarget:self action:@selector(accessoryButtonTapped:event:)  forControlEvents:UIControlEventTouchUpInside];

之后加上:

- (void)accessoryButtonTapped:(id)sender event:(id)event
{
    NSSet *touches = [event allTouches];
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchPosition = [touch locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
    if (indexPath != nil) {
        [self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath];
    }
} 

(copied verbatim from this link)

请注意,这一假设假定是在UITableViewController(就我的情况而言,Im在一门习俗室中制造一只,因此参考文献略有不同)创建的。

解释:从属ButtonTapped是我们习俗纽扣的一种习俗目标方法。 当 but子受到压力时(“TouchUpInside”),我们发现电池的指数出现在新闻发生的时刻,并采用表格中通常采用的方法。





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签