2010-06-15 3 views

답변

3

검색 막대를 만들고 텍스트 상자를 하위보기로 추가했습니다.

UIAlertView * myAlertView = [[UIAlertView alloc] initWithTitle:@"   " 
                 message:@"   " 
                 delegate:self 
              cancelButtonTitle:nil 
              otherButtonTitles:nil, nil]; 
UISearchBar *myTextField = [[UISearchBar alloc] initWithFrame:CGRectMake(30.0, 35.0, 180.0, 35.0)]; 
UIButton *searchbtn = [[UIButton alloc] initWithFrame:CGRectMake(230.0, 35.0, 40.0, 35.0)]; 
[myTextField setBackgroundColor:[UIColor whiteColor]]; 
[myAlertView setBackgroundColor:[UIColor grayColor]]; 
[searchbtn setBackgroundColor:[UIColor grayColor]]; 
[myAlertView addSubview:myTextField]; 
[myAlertView addSubview:searchbtn]; 

더 좋은 방법이 있으면 알려 주시기 바랍니다.

1

더 나은 방법이있다 :

UIAlertView *myAlertView = [[[UIAlertView alloc] initWithTitle:@"Keyword Search" 
                  message:@"" 
                  delegate:self 
               cancelButtonTitle:nil 
               otherButtonTitles:@"Search", nil] autorelease]; 

    myAlertView.alertViewStyle = UIAlertViewStylePlainTextInput; 
    [myAlertView show]; 

그리고 위임에 :

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 
    NSString *searchTerm = [alertView textFieldAtIndex:0].text; 
} 
관련 문제