[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
'iPhone'에 해당되는 글 170건
- 2013.07.26 [objc] UIWebView, 배경을 투명하게
- 2013.07.19 [objc] UITextView 높이 구하기
- 2013.07.17 [objc] UITextView, 복사/붙여넣기 팝업이 안나오는 UITextView 만들기
- 2013.07.16 [objc] UITableView, scroll만 가능하게
- 2013.07.10 [objc] UITextView, url link
- 2013.07.10 [objc] 제스쳐, 싱글탭 더블탭 동시에, gesture, single tap, double tap
- 2013.07.02 [objc] frame, layout, CGRect, 레이아웃 재정의
- 2013.06.30 [objc] strings file, localize
- 2013.06.26 [objc] Album, privacy alert
- 2013.06.10 [objc] JSON 문자열, 파싱
- 2013.06.07 [objc] 단말이 플래시가 있는지 체크하기
- 2013.06.06 [objc] UITextField, placeholder만 사이즈 바꾸기
- 2013.06.06 [objc] UITextField, textField:shouldChangeCharactersInRange:replacementString:에서 수정후의 문자열 얻기
- 2013.06.04 [objc] UILabel align left top
- 2013.05.31 [objc] UIWebView, Network check
- 2013.05.31 [objc] UIWebViewDelegate가 안먹는다?
- 2013.05.30 [objc] UIWebView, cache
- 2013.05.30 [objc] UILabel, line
- 2013.05.30 [objc] use Autolayout
- 2013.05.27 [objc] BOOL 타입을 NSDictionary에 넣고 싶을 때
- 2013.05.17 [objc] 스크롤은 되고, copy,paste 팝업은 안나오는 TextView
- 2013.05.13 [objc] ARC, block coding self 참조
- 2013.05.10 [objc] UIButton -> UIBarButtonItem
- 2013.05.09 [objc] UIBarButtonItem, 회전
- 2013.05.09 [objc] NSMutableDictionary, 두개의 NSDictionary 통합
- 2013.05.08 [objc] UINavigationBar, back btn
- 2013.05.07 [objc] UIImage, resize image
- 2013.04.24 [objc] UIWebView 스크롤막기
- 2013.04.24 [objc] 키보드 리턴키 텍스트 바꾸기
- 2013.04.22 [objc] UIButton에 이벤트를 설정했을때 EXC_BAD_ACCESS
CGSize textViewSize = [text sizeWithFont:[UIFont fontWithName:@"Marker Felt" size:20]
constrainedToSize:CGSizeMake(WIDHT_OF_VIEW, FLT_MAX)
lineBreakMode:UILineBreakModeTailTruncation];
사용하려는 클래스의 .m파일 끝에 붙이면 됨.
@implementation UITextView (DisableCopyPaste)
- (BOOL)canBecomeFirstResponder
{
return NO;
}
@end
http://stackoverflow.com/questions/1426731/how-disable-copy-cut-select-select-all-in-uitextview
NSArray *cells = self.tableView.visibleCells;
for(UITableViewCell *cell in cells){
cell.userInteractionEnabled = NO;
}
*** 이렇게 하면 보이는 셀만 잠근다.
스크롤 하면 재사용해서 셀을 돌리기 때문에 꼬인다.
셀을 생성하는 구문도 수정필요.
textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;
// ****** 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
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;
Localize를 위한 스트링파일 읽기.
self.title = NSLocalizedString(@"MainViewTitle", @"");
http://userflex.wordpress.com/2011/10/20/localized-strings-xcode4/
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
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);
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([device hasTorch])
{
...
}
http://stackoverflow.com/questions/15247175/how-to-find-out-camera-flash-is-available-in-iphone
//뷰가 로드될때, 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;
}
[objc] UITextField, textField:shouldChangeCharactersInRange:replacementString:에서 수정후의 문자열 얻기
iPhone 2013. 6. 6. 17:21
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
...
NSString *changedStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
return YES;
}
UILabel이 중앙정렬때문에 레이아웃이 자꾸깨져 짜증남.
sizeToFit로 해결됨. 아주 깨끗히
UILabel
sizeToFit
http://stackoverflow.com/questions/1054558/vertically-align-text-within-a-uilabel
- (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);
}
NSObject에 <UIWebViewDelegate>선언하고
웹뷰의 델레게이트에 연결해도 안먹길래..
뭔가 수상해서.
UIViewController에 <UIWebViewDelegate> 선언하고,
거기에 델레게이트 연결하니까 먹더라.
... 델레게이트 구현하는 곳이 뷰컨트롤러여야되나?...
NSURLRequest initWithURL:cachePolicy:timeoutInterval
cachePolicy: NSURLCacheStorageNotAllowed
하거나
[[NSURLCache sharedURLCache] removeCachedResponseForRequest:targetRequest];
하면 된다고 하는데?
label.numberOfLines = 3;
label.lineBreakMode = UILineBreakModeWordWrap;
넣을 때
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
1. UITextView를 상속받은 클래스에 이하의 메소드를 만듦.
대충 클래스 이름을 TextView1..
- (BOOL)canBecomeFirstResponder {
return NO;
}
2. TextView를 쓰는 곳에서
UITextView *tv = [[TextView1 alloc] init...
ARC를 사용할때, block 코딩에서 self를 참조하면 메모리 누수가 있는 모양.
weak로 재정의해서 사용하면 된다고 한다.
하지만 매번 클래스명을 쓰기도 귀찮고 할때.
__weak typeof(self) selfBlock = self;
UIButton *button = ...
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
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가 초기치인듯.
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;
}
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;
webView.scrollView.scrollEnabled = NO;
webView.scrollView.bounces = NO;
http://stackoverflow.com/questions/6437911/disable-scroll-on-a-uiwebview-allowed
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
ARC를 사용할때의 문제.
핸들러가 불릴때, 이미 인스턴스가 메모리에서 해제되면서 생기는 문제.
메모리에서 해제되지 않게 변수에 붙들어 매어두면 해결. (strong으로)