Note that there are some explanatory texts on larger screens.

plurals
  1. POSafari web browse not open with URL
    primarykey
    data
    text
    <p>I am new at iPhone Development. I have Table view with 6 section each section has one row, in 4Th Section i add UILabel. This UILabel text is URL (www.google.com). I want to open safari when i click on This label but i am not success for open safari</p> <p>i follo this <a href="https://stackoverflow.com/questions/5928868/uilabel-with-a-hyperlink-inside-a-uitableviewcell-should-open-safari-webbrowser">UILabel with a hyperlink inside a UITableViewCell should open safari webbrowser?</a> </p> <p>But it not work.</p> <p><strong>My code:</strong></p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.backgroundColor = [Prep defaultBGColor]; if(indexPath.section == 3) { self.lblWebsite = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 270, 35)]; self.lblWebsite.backgroundColor = [UIColor clearColor]; self.lblWebsite.text= @"www.gmail.com"; self.lblWebsite.font =[UIFont fontWithName:@"Arial-BoldMT" size:16]; self.lblWebsite.textAlignment = UITextAlignmentLeft; self.lblWebsite.userInteractionEnabled = YES; self.lblWebsite.textColor=[UIColor blackColor]; [cell.contentView addSubview:self.lblWebsite]; UITapGestureRecognizer *gestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openUrl:)]; gestureRec.numberOfTouchesRequired = 1; gestureRec.numberOfTapsRequired = 1; [self.lblWebsite addGestureRecognizer:gestureRec]; [gestureRec release]; } } return Cell; } </code></pre> <p><strong>Method</strong></p> <pre><code>- (void)openUrl:(id)sender { UIGestureRecognizer *rec = (UIGestureRecognizer *)sender; id hitLabel = [self.view hitTest:[rec locationInView:self.view] withEvent:UIEventTypeTouches]; if ([hitLabel isKindOfClass:[UILabel class]]) { NSLog(@"%@",((UILabel *)hitLabel).text); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.google.com"]]; } } </code></pre> <p>Here what is my mistake ??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload