'iPhone'에 해당되는 글 170건

  1. 2013.07.26 [objc] UIWebView, 배경을 투명하게
  2. 2013.07.19 [objc] UITextView 높이 구하기
  3. 2013.07.17 [objc] UITextView, 복사/붙여넣기 팝업이 안나오는 UITextView 만들기
  4. 2013.07.16 [objc] UITableView, scroll만 가능하게
  5. 2013.07.10 [objc] UITextView, url link
  6. 2013.07.10 [objc] 제스쳐, 싱글탭 더블탭 동시에, gesture, single tap, double tap
  7. 2013.07.02 [objc] frame, layout, CGRect, 레이아웃 재정의
  8. 2013.06.30 [objc] strings file, localize
  9. 2013.06.26 [objc] Album, privacy alert
  10. 2013.06.10 [objc] JSON 문자열, 파싱
  11. 2013.06.07 [objc] 단말이 플래시가 있는지 체크하기
  12. 2013.06.06 [objc] UITextField, placeholder만 사이즈 바꾸기
  13. 2013.06.06 [objc] UITextField, textField:shouldChangeCharactersInRange:replacementString:에서 수정후의 문자열 얻기
  14. 2013.06.04 [objc] UILabel align left top
  15. 2013.05.31 [objc] UIWebView, Network check
  16. 2013.05.31 [objc] UIWebViewDelegate가 안먹는다?
  17. 2013.05.30 [objc] UIWebView, cache
  18. 2013.05.30 [objc] UILabel, line
  19. 2013.05.30 [objc] use Autolayout
  20. 2013.05.27 [objc] BOOL 타입을 NSDictionary에 넣고 싶을 때
  21. 2013.05.17 [objc] 스크롤은 되고, copy,paste 팝업은 안나오는 TextView
  22. 2013.05.13 [objc] ARC, block coding self 참조
  23. 2013.05.10 [objc] UIButton -> UIBarButtonItem
  24. 2013.05.09 [objc] UIBarButtonItem, 회전
  25. 2013.05.09 [objc] NSMutableDictionary, 두개의 NSDictionary 통합
  26. 2013.05.08 [objc] UINavigationBar, back btn
  27. 2013.05.07 [objc] UIImage, resize image
  28. 2013.04.24 [objc] UIWebView 스크롤막기
  29. 2013.04.24 [objc] 키보드 리턴키 텍스트 바꾸기
  30. 2013.04.22 [objc] UIButton에 이벤트를 설정했을때 EXC_BAD_ACCESS



[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];


http://stackoverflow.com/questions/8667150/uiwebview-background-is-set-to-clear-color-but-it-is-not-transparent

Posted by tenn
,



CGSize textViewSize = [text sizeWithFont:[UIFont fontWithName:@"Marker Felt" size:20] 
                       constrainedToSize:CGSizeMake(WIDHT_OF_VIEW, FLT_MAX) 
                       lineBreakMode:UILineBreakModeTailTruncation];



http://stackoverflow.com/questions/7401445/how-to-set-height-of-uitextview-according-to-its-content-in-objective-c

Posted by tenn
,


사용하려는 클래스의 .m파일 끝에 붙이면 됨.


@implementation UITextView (DisableCopyPaste)

- (BOOL)canBecomeFirstResponder
{
    return NO;
}

@end



http://stackoverflow.com/questions/1426731/how-disable-copy-cut-select-select-all-in-uitextview

Posted by tenn
,


    NSArray *cells = self.tableView.visibleCells;

    for(UITableViewCell *cell in cells){

        cell.userInteractionEnabled = NO;

    }


*** 이렇게 하면 보이는 셀만 잠근다.

스크롤 하면 재사용해서 셀을 돌리기 때문에 꼬인다.

셀을 생성하는 구문도 수정필요.

Posted by tenn
,

[objc] UITextView, url link

iPhone 2013. 7. 10. 19:09



textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;


http://stackoverflow.com/questions/995219/how-to-make-uitextview-detect-links-for-website-mail-and-phone-number



Posted by tenn
,


// ****** gesture recognizers ******

{   // single tap    
    UITapGestureRecognizer *single_tap_recognizer;

    single_tap_recognizer = [[[UITapGestureRecognizer alloc] 
                    initWithTarget : table_view_controller  
                    action         : @selector(upper_button_view_tapped:)]
                    autorelease];

    [single_tap_recognizer setNumberOfTouchesRequired : 1];
    [u_buttons_view addGestureRecognizer : single_tap_recognizer];


    // double tap 
    UITapGestureRecognizer *double_tap_recognizer;

    double_tap_recognizer = [[[UITapGestureRecognizer alloc] 
                     initWithTarget : table_view_controller  
                     action         : @selector
                              (upper_button_view_double_tapped:)]
                     autorelease];        

    [double_tap_recognizer setNumberOfTouchesRequired : 2];

    [single_tap_recognizer requireGestureRecognizerToFail : double_tap_recognizer]; 

    [u_buttons_view addGestureRecognizer : double_tap_recognizer];



http://stackoverflow.com/questions/8876202/uitapgesturerecognizer-single-tap-and-double-tap

Posted by tenn
,

     


UIView *a = ...


        CGRect target = a.frame;

        a.frame = CGRectMake(target.origin.x, target.origin.y, target.size.width, target.size.height);



간단히..

CGRect target = a.frame;

target.origin.x = 0;

target.size.width = 100;

a.frame = target;




Posted by tenn
,

Localize를 위한 스트링파일 읽기.


self.title = NSLocalizedString(@"MainViewTitle", @"");


http://userflex.wordpress.com/2011/10/20/localized-strings-xcode4/


Posted by tenn
,

[objc] Album, privacy alert

iPhone 2013. 6. 26. 12:22

Album Privacy 설정 경고창을 표시.

(설정안하면 경고창, 설정했으면 표시안함)

iOS6이상.. (5이하는 앨범프라이버시 설정이 안된다)


ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];

[lib enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    NSLog(@"%i",[group numberOfAssets]);
} failureBlock:^(NSError *error) {
    if (error.code == ALAssetsLibraryAccessUserDeniedError) {
        NSLog(@"user denied access, code: %i",error.code);
    }else{
        NSLog(@"Other error code: %i",error.code);
    }
}];

http://stackoverflow.com/questions/13572220/ask-permission-to-access-camera-roll

Posted by tenn
,



    NSString *str = @"{\"flg\":\"1\"}";

    NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];

    NSError *err = nil;

    id result = [NSJSONSerialization JSONObjectWithData:data options:0 error:&err];

    NSDictionary *dic = result;

    NSString *p1 = [dic objectForKey:@"flg"];

    NSLog(@"%@", p1);

Posted by tenn
,



AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

if([device hasTorch])

{

...

}



http://stackoverflow.com/questions/15247175/how-to-find-out-camera-flash-is-available-in-iphone

Posted by tenn
,


//뷰가 로드될때, UITextField에 placeholder의 폰트 사이즈 지정


//UITextFieldDelegate


- (BOOL)textFieldShouldClear:(UITextField *)textField{

//placehoder사이즈를 UITextField에 지정

return YES;

}


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {


...

 

        NSString *changedStr = [textField.text stringByReplacingCharactersInRange:range withString:string];

        

        if([changedStr isEqualToString:@""]){

            //placehoder사이즈를 UITextField에 지정

        }else{

            //입력문자 사이즈를 UITextField에 지정

        }


return YES;


}

Posted by tenn
,




- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {


...


    NSString *changedStr = [textField.text stringByReplacingCharactersInRange:range withString:string];

    return YES;


}

Posted by tenn
,

UILabel이 중앙정렬때문에 레이아웃이 자꾸깨져 짜증남.

sizeToFit로 해결됨. 아주 깨끗히


UILabel 

sizeToFit



http://stackoverflow.com/questions/1054558/vertically-align-text-within-a-uilabel

Posted by tenn
,


- (BOOL) connectedToInternet

{

    NSString *URLString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]];

    return ( URLString != NULL ) ? YES : NO;

}





stringWithContentsOfURL <- 요놈이 deprecated됨.


NSError* error = nil;
NSString* text = [NSString stringWithContentsOfURL:TheUrl encoding:NSASCIIStringEncoding error:&error];
if( text )
{
    NSLog(@"Text=%@", text);
}
else 
{
    NSLog(@"Error = %@", error);
}


http://stackoverflow.com/questions/2039203/what-is-the-stringwithcontentsofurl-replacement-for-objective-c

Posted by tenn
,

NSObject에 <UIWebViewDelegate>선언하고

웹뷰의 델레게이트에 연결해도 안먹길래..

뭔가 수상해서.

UIViewController에 <UIWebViewDelegate> 선언하고,

거기에 델레게이트 연결하니까 먹더라.


... 델레게이트 구현하는 곳이 뷰컨트롤러여야되나?...


Posted by tenn
,

[objc] UIWebView, cache

iPhone 2013. 5. 30. 18:46

NSURLRequest initWithURL:cachePolicy:timeoutInterval

cachePolicy: NSURLCacheStorageNotAllowed


하거나

[[NSURLCache sharedURLCacheremoveCachedResponseForRequest:targetRequest];


하면 된다고 하는데?

Posted by tenn
,

[objc] UILabel, line

iPhone 2013. 5. 30. 16:55

        label.numberOfLines = 3;

        label.lineBreakMode = UILineBreakModeWordWrap;

Posted by tenn
,

[objc] use Autolayout

iPhone 2013. 5. 30. 14:18



http://www.raywenderlich.com/ko/21139/ios-6%EC%97%90%EC%84%9C-%EC%98%A4%ED%86%A0-%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-%ED%8C%8C%ED%8A%B8-1-1

Posted by tenn
,

넣을 때


NSMutableDictionary *dic = ...


[dic setValue:[NSNumber numberWithBool:YES] forKey:@"bool"];




꺼낼 때


NSNumber *num = [dic objectForKey:@"bool"];

if([num compare:[NSNumber numberWithBool:NO]] == NSOrderedSame) {

//do something;

}




http://stackoverflow.com/questions/2478984/how-to-convert-and-compare-nsnumber-to-bool



Posted by tenn
,


1. UITextView를 상속받은 클래스에 이하의 메소드를 만듦.

  대충 클래스 이름을 TextView1..


- (BOOL)canBecomeFirstResponder {  

    return NO;

}


2. TextView를 쓰는 곳에서


UITextView *tv = [[TextView1 alloc] init...





Posted by tenn
,

ARC를 사용할때, block 코딩에서 self를 참조하면 메모리 누수가 있는 모양.

weak로 재정의해서 사용하면 된다고 한다.

하지만 매번 클래스명을 쓰기도 귀찮고 할때.


__weak typeof(self) selfBlock = self;

Posted by tenn
,

UIButton *button = ...


UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

self.navigationItem.leftBarButtonItem = customBarItem;


Posted by tenn
,

CGAffineTransform myTransform = CGAffineTransformMakeRotation(
M_PI);

UIBarButtonItem * currentItem =  self.navigationItem.leftBarButtonItem;

currentItem.customView.transform = myTransform;


self.navigationItem.leftBarButtonItem.customView.layer.anchorPoint = CGPointMake(0.6, 0.7);



//anchorPoint 회전축. 0.5 0.5가 초기치인듯. 

Posted by tenn
,



    NSMutableDictionary *dic1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1",@"one",@"2",@"two", nil];

    NSDictionary *dic2 = [[NSDictionary alloc] initWithObjectsAndKeys:@"3",@"three",@"4",@"four", nil];

    

    [dic1 addEntriesFromDictionary:dic2];




***결과

{

    four = 4;

    one = 1;

    three = 3;

    two = 2;

}

Posted by tenn
,



UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

[button setImage:buttonImage forState:UIControlStateNormal];

button.frame = CGRectMake(0, 0, 45, 45);

[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

self.navigationItem.leftBarButtonItem = customBarItem;

Posted by tenn
,




http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage

Posted by tenn
,


webView.scrollView.scrollEnabled = NO; 
webView.scrollView.bounces = NO;


http://stackoverflow.com/questions/6437911/disable-scroll-on-a-uiwebview-allowed



Posted by tenn
,


typedef enum {
   UIReturnKeyDefault,
   UIReturnKeyGo,
   UIReturnKeyGoogle,
   UIReturnKeyJoin,
   UIReturnKeyNext,
   UIReturnKeyRoute,
   UIReturnKeySearch,
   UIReturnKeySend,
   UIReturnKeyYahoo,
   UIReturnKeyDone,
   UIReturnKeyEmergencyCall,
} UIReturnKeyType;


http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html#//apple_ref/occ/intfp/UITextInputTraits/returnKeyType

Posted by tenn
,



ARC를 사용할때의 문제.


핸들러가 불릴때, 이미 인스턴스가 메모리에서 해제되면서 생기는 문제.

메모리에서 해제되지 않게 변수에 붙들어 매어두면 해결. (strong으로)




http://blog.f60k.com/arc_uibutton_exc_bad_access/

Posted by tenn
,