2011-10-19 3 views
0

첫 번째 단추에 프로그래밍 방식으로 단추를 가져 가고 싶습니다. 내 고객 전화 번호가 단추를 누른 다음 사용자가 전화를 걸어 표시됩니다. 내있는 tableview에서 내가 다음 코드를 붙여 넣은응용 프로그램에서 전화 걸기 방법

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:%@"]; 

그리고 행동에

I을 적용해야하는지 논리 실제로
-(void) phonecall:(id)sender 
{ 
marker *aMarker = [[marker alloc] init]; 
    tel:aMarker.phone; 
    } 

그 전화 번호 버튼을 눌러 때 동일하므로 번호가 호출됩니다.

+0

메이커는 무엇입니까? – Maulik

+0

URL에서 xml 데이터를 파싱 중입니다. 마커는이 속성입니다. 전화 번호 (aMarker.phone), 주소 ....... –

답변

0

에서 "aMarker.phone"을 가져 오는 중입니다. 아래 코드를 사용하여 전화를 걸 수 있습니다. 코드에 따라

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

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

thats 같은 정보가 포함되어 있습니다 또한 전에 시도했습니다. 그러나 나는 마커 인 URL에서 전화 번호를 가져오고 있습니다. 전화. 전화를 걸려면 테이블 뷰의 각 번호를 어떻게 할당 할 수 있습니까? –

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; 

     } 

희망 당신에게 도움이 코드에 기록 된 호출 전화를위한 도움이됩니다.