English 中文(简体)
• 如何在《联邦法典》中采取劳工行动?
原标题:how to get UILabel action in UITableView?
  • 时间:2012-01-13 11:59:57
  •  标签:
  • ios

在表格的每个单元中,我有3个工匠。 我增加了对每一方的主承姿态,但当其被利用时,我如何掌握所开发的浏览指数道路?

我的法典

UILabel *tit_lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,10,280,45)];
[tit_lbl setText:[[final_dictionaires_array objectAtIndex:indexPath.row] objectForKey:title]];
[tit_lbl setUserInteractionEnabled:YES];
[tit_lbl setTag:indexPath.row];
[btn addSubview:tit_lbl];
[tit_lbl release];

UITapGestureRecognizer* tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToArticleDetailsView:)];
[tit_lbl addGestureRecognizer:tapRecognizer];
[tapRecognizer release];

通过这样做,我可以采取标签行动,但我希望得到哪一个标签被点击? (每行有3个标签)。

最佳回答

我同意关于使用带宽带的习惯风格,而不是使用标签和姿态识别器进行基本重新计算的建议。 然而,你仍然有同样的问题。 哪一个标签被打上? 表中哪一行?

您可以发现,通过向每一方分配标签,然后对姿态识别器的<代码>view财产进行查询,可以发现哪些标签被篡改。 姿态识别器是你走到To条详细表述方法中的论点:

-(void)goToArticleDetailsView:(id)sender
{
    UITapGestureRecognizer *tapGR = (UITapGestureRecognizer*)sender;
    if (tapGR.view.tag == 1)
        // tapGR.view is the label that the gesture recognize was attached to

您可以发现,该表的哪一行是利用“姿态识别器”<代码>、所在地OfTouch方法,以及“UITableView sindexPathForRowAtPoint:。 方法:

CGPoint touchLocation = [tapGR locationOfTouch:0 inView:self.tableView];
NSIndexPath *tappedRow = [self.tableView indexPathForRowAtPoint:touchLocation];
问题回答

无法点击“IDLabel”。 如果你想要让用户与这些价值观互动,那么你就应当使用UITextfield。

为了采取行动,你应向UIText Field发出电文。

进入适当的牢房,可以使用“指数”。

good





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签