2014년 4월 5일 토요일

iphone UIActionSheet example


1. .m 상단에 tag 정의

#define TAG_ACTION_SHEET 11111

2. .h 에 delegate 추가

@interface SignUpViewController : UIViewController <UIActionSheetDelegate> 

3. .m 특정 버튼 클릭시
- (IBAction)clickPhoto:(id)sender

{
UIActionSheet *popup = [[UIActionSheet allocinitWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
                            @"camera",
                            @"album",
                            nil];
     popup.tag = TAG_ACTION_SHEET;

    [popup showInView:[UIApplication sharedApplication].keyWindow];
}

4. .m event 처리부분

- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    switch (popup.tag) {
        case TAG_ACTION_SHEET: {
            switch (buttonIndex) {
                case 0:
                    NSLog("camera");
                    break;
                case 1:
                    NSLog("album");
                    break;
                default:
                    break;
            }
            break;
        }
        default:
            break;
    }
}

2014년 3월 18일 화요일

jquery 한글만 입력

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

$("input[name=textfield1]").keyup(function(event){

regexp = /[a-z0-9]|[ \[\]{}()<>?|`~!@#$%^&*-_+=,.;:\"'\\]/g;
v = $(this).val();
if( regexp.test(v) ) {
alert("한글만입력하세요");
$(this).val(v.replace(regexp,''));
}
});

});


</script>
</head>
<body>
<h1>한글만입력</h1>
<h2></h2>
<h3><input type="text" name="textfield1"/></h3>
</body>
</html>