2011-10-19 11 views
0

私は最初のボタンでプログラム的にボタンを取りたいと思っています。私の顧客の電話番号は、ボタンをタップして表示して、ユーザが呼び出すことができます。私のテーブルビューでは、私はアプリケーションから電話をかける方法

marker *aMarker = [[marker alloc] init]; 
    PhoneLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 45, 30, 20)] autorelease]; 
    PhoneLabel.tag = kPhoneLabelTag; 
    PhoneLabel.font = [UIFont systemFontOfSize:14]; 
    [cell.contentView addSubview:PhoneLabel]; 

      PhoneB = [UIButton buttonWithType:UIButtonTypeCustom]; 
     [PhoneB setTitle:aMarker.phone forState:UIControlStateNormal]; 
    PhoneB.frame = CGRectMake(15, 45, 200, 20); 
    PhoneB.font = [UIFont systemFontOfSize:14]; 
    PhoneB.titleLabel.textColor = [UIColor blackColor]; 
    [cell.contentView addSubview:PhoneB]; 
    [cell addSubview:PhoneB]; 
    [GetDirectionB addTarget:self 
         action:@selector(phonecall:) 
      forControlEvents:UIControlEventTouchUpInside]; 

phonelabelは、電話番号のボタンを同じにタップしたときになるように、実際のロジックは、私が適用されるべきか

   PhoneLabel.text = [NSString stringWithFormat:@"p:%@"]; 

とアクション

-(void) phonecall:(id)sender 
{ 
marker *aMarker = [[marker alloc] init]; 
    tel:aMarker.phone; 
    } 

上で、次のコードを貼り付けています番号が呼び出されます。 URLから「aMarker.phone」を取得しています

+0

メーカーとは? – Maulik

+0

URLからxmlデータを解析しています。マーカーはこれの属性です。電話番号(aMarker.phone)、アドレス........... –

答えて

0

以下のコードを使用して電話をかけることができます。次のコード

-(void) phonecall:(id)sender 
{ 
    NSString *number = @"123456..." // a phone nuber 
    NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",number]]; 

    [[UIApplication sharedApplication] openURL:phoneNumberURL]; 
} 
+0

の情報も入っていますしかし、私はUrlからaMarker.phoneである電話番号を取得しています。テーブルビュー内のそれぞれの番号をコールするにはどうすればよいですか –

2
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://your number"]]; 
0

は、ラベルにこのコードがあなたに助け

if(![[UIDevice currentDevice].model isEqualToString:@"iPhone"]) 
     { 
     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:_ALERT_TITLE_MSG 
                  message:@"This Phone is not support call facility" 
                  delegate:self 
                cancelButtonTitle:@"Ok" 
                otherButtonTitles: nil]; 
     [alertView show]; 
     [alertView release]; 
     }else { 
      if([lblTel.text length]>0) 
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",lblTel.text,nil]]]; 
      else 
       btnCallTapped.hidden=YES; 

     } 

希望を書かれているコール電話のヘルプです。

関連する問題