[mystring stringByReplacingOccurrencesOfString:@"searchString" withString:@"replaceString" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mystring length])];
[mystring stringByReplacingOccurrencesOfString:@"searchString" withString:@"replaceString" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mystring length])];
탭바를 숨기기/보이기를 할때, UIView를 늘여서 움직임을 만들면,
iOS5/6에서 탭바영역이 화면을 가리는 현상이 발생.
iOS7에서는 문제없이 동작.
삽질하다가 좋은 예문을 찾음.
http://stackoverflow.com/questions/5272290/how-to-hide-uitabbarcontroller
// Method implementations
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
-(void) aaa:(void(^)(id abc))complete{
}
- (void)bbbWithComplete:(void(^)(void))success{
}
NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString:str];
str가 nil일 경우, 앱에 종료된다.
xcode5에서 빌드할때,
레이아웃에 문제가 생기는 경우.
크게 두가지로 나뉜다.
1. 스테이터스바 침식
2. 네비게이션바 침식
해결책으로 이하의 자료를 발견
http://qiita.com/cyan_ishii/items/0babccb20c0f183b1c5f
하지만 잘 듣지 않았다.
iOS7에서는 표시가 바르게 되었지만,
iOS6이하에서는 레이아웃이 전체적으로 위로 밀리는 현상이 발생.
예전의 방법으로 뷰컨트롤러의 뷰의 프레임을 임의로 조정하거나.
스토리보드에서 델타(iOS 6/7 Deltas)를 조정해도 반영되지 않았다.
뷰컨트롤러의 뷰에 다시 레이아웃용의 뷰를 올려서 레이아웃을 구성하면,
레이아웃용 뷰는 조정이 먹으므로(스토리보드의 델타보정도 가능)
해결.(진짜?)
추가 >
다필요없고.
iOS7미만에서 이상있는 것은
사용하는 네비게이션 컨트롤러에서 translucent의 체크를 해제해주면 된다.
스토리 보드에서 네비게이션컨트롤러안에 있는 네비게이션 바를 선택하면 선택 체크박스가 나타난다.
특히 네비게이션 갈아타고 다니는 경우에 스토리보드에서 네비게이션바 다 찾아서 해제해줘야 한다.
iOS5/6에서도 네비게이션 바가 투명하면 화면이 바 밑으로 들어간다고 한다.
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
and use them like this:
if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
// code here
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
// code here
}
- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
가로로 늘릴 때는 UIEdgeInsets의 top, bottom은 0.
참고 : http://www.appcoda.com/customize-navigation-bar-back-butto/
(그림 보면 이해가 쉬움)
** 다음의 경우에는 쓰면 안됨.
중간 부분의 이미지가 질감인 경우. (타일패턴으로 채우기때문에 부자연스럽게 보임)
git checkout [branch] [file]
하면 파일 하나만 가져온다.
git reset HEAD [file]
git revert [commit 명]
이전의 커밋으로 되돌림.
이력이 남음.
(이력이 남지 않는 것은 git reset)
새로 프로젝트를 생성해서 스토리보드를 보니 뭔가 많이 바뀌어있다...
스토리보드의 UI오브젝트의 frame의 값을 고쳐도 먹지를 않는다.
코드에서 생성한 UI오브젝트는 중간에 고쳐도 잘 먹는데...
Size Inspector의 GUI가 뭔가 변했는데 관계가 있는듯?
constraints가 더덕더덕 붙어있는게... ;;
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"ボタン"];
NSDictionary *attributes = @{ NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};
[attrStr addAttributes:attributes
range:NSMakeRange(0, attrStr.length)];
[self.btn setAttributedTitle:attrStr forState:UIControlStateNormal];
NSString *str = @"part1 part2 part3";
NSRange range = [str rangeOfSring:@"part2"];
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"ボタン"];
/* フォント */
[attrStr addAttribute:NSFontAttributeName
value:[UIFont fontWithName:@"ChalkboardSE-Regular" size:30.f]
range:NSMakeRange(0, attrStr.length)];
/* 文字色 */
[attrStr addAttribute:NSForegroundColorAttributeName
value:[UIColor cyanColor]
range:NSMakeRange(0, attrStr.length)];
// 中抜き文字の枠線の色、下線、カーニングを一度に指定
NSDictionary *attributes = @{NSStrokeColorAttributeName: [UIColor magentaColor],
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSKernAttributeName: @1.5};
NSString *tStr = @"ボタン";
[attrStr addAttributes:attributes
range:[tStr rangeOfString:@"ボ"]];
[yourButton setTitle:@"your title" forState:UIControlStateNormal];
[yourButton setTitle:@"your title" forState:UIControlStateSelected];
[yourButton setTitle:@"your title" forState:UIControlStateHighlighted];
UILabel을 사용할 때 NSString의 sizeWithFont를 사용하듯,
OHAttributedLabel을 사용하면, 자간의 차이 때문에 (일본어를 사용할 시에행간이 달라짐)
height의 결과가 달라진다.
특히 테이블에 넣었을 때, 애로사항이 꽃핀다.
해결방법으로는 구글 선생님과 상담결과 행간을 조절한다. 라고 하는데
뭘 잘못했는지 잘 안됨.
http://eikatou.net/blog/2012/09/ios_rich_uilabel_2/
CoreText의 버그라는 말도 보인다.
http://cafe.naver.com/mcbugi/255603
일본어의 문제는 인식하고 있지만, 영어의 문제는 확인하지 않았다.
//행간을 조절할 수 있다는데 테스트해보지 않음.
NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:str];
// [attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)];
http://stackoverflow.com/questions/7370013/how-to-set-kerning-in-iphone-uilabel
다른 방법이 없는 지 몇시간을 파닥대다가...
OHAttributedLabel에 문자열을 넣을 때, NSString이 아닌 NSAttributeString을 넣고,
계산할 때, NSAttributedString의 sizeConstrainedToSize를 사용하면, 달라진 자간에 대한 정확한 결과를 얻을수 있는 듯하다.
Local branch 삭제
git branch -d hoge
remote branch 삭제
git push --delete origin hoge
혹은
Local
$ git branch -D bugfix
Remote
$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).
$ git push
http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely
UITextField의 외곽선을 이미지로 했을 때, 고민하게 되는 문제.
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone
스토리보드에서 스토리보드로 복사할때,
안의 컴포넌트의 좌표와 크기가 흐트러질 때가 있다.
storyboard > Interface Builder Document > use AutoLayout
을 비활성화 하면, 스토리복사를 해도 좌표정보가 변하지 않는다.
self.navigationItem.hidesBackButton = YES;
따위도 안먹고 곤란할 때.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
button.hidden = YES;
self.navigationItem.leftBarButtonItem = customBarItem;
이게 되더라..
//////
self.navigationItem
self.navigationController.navigationItem