UITextView text length limitation

iOS8 以上键盘的自动联想功能使UITextView的长度限制产生一些bug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#define textLimitLength 50
#pragma mark - UITextViewDelegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if (textView.text.length >= textLimitLength && text.length > range.length) {
return NO;
}
return YES;
}
- (void)textViewDidChange:(UITextView *)textView {
if (textView.markedTextRange == nil && textView.text.length > textLimitLength) {
textView.text = [textView.text substringToIndex:textLimitLength];
}
}

reactive cocoa note

Observe textField.text changing

1
2
3
4
//only RACObserve(self.textField, text) or self.textField.rac_textSignal will not working
RACSignal *textFieldTextSignal = [RACSignal merge:@[RACObserve(self.textField, text),self.textField.rac_textSignal]];
[textFieldTextSignal subscribeNext:block];

Combine two signals

1
2
3
4
5
6
7
8
void(^block)(RACTuple *) = ^(RACTuple *tuple) {
NSString *x = tuple.first;
NSString *y = tuple.second;
//do something
};
[[RACSignal combineLatest:@[signal1,signal2]] subscribeNext:block];

reveal crisis

27岁生日前一天,入手了正版reveal
装了 reveal loader没的反应
看了这篇教程
这**的blog

4、将libReveal.dylib上传到设备的/Library/MobileSubstrate/DynamicLibraries

6、re-spring或重启iOS设备,打开你想看的app,再从Reveal界面左上角选择要连接的机器,进入不同的页面之后还可以点击右上角的刷新钮来刷新监测的页面信息。

这步我的iphone 就无限 apple logo 了,
差点就用 itunes restore 了

幸好看到了这个哥们的视频
解决的了无限logo
方法就是按住音量上30秒或以上

但是启动了手机之后所有cydia 插件都不能用了, 超雪 afc2add 都没的了,多半是 libReveal.dylib 把cydia 的auto load 卡到了,

ifunbox 也不能打开 iphone 的root file system,

不过openssh 还可以用, 用ssh 到手机果断 rm /Library/MobileSubstrate/DynamicLibraries/libReveal.dylib

重启手机完全正常.

reveal crisis

fin

#解决办法

Reveal 1.5.x 會讓 SpringBoard crash

正確解法是新增 libReveal.plist 設定 filter (對,我以前懶惰都不設定)

Bundle 設定一個不存在的值就好了,例如 com.apple.Tabemonodesuyo

之後裝 Reveal Loader,用 loader 去控制要在哪個 App 執行就好,

Injecting Reveal With MobileSubstrate

1
2
3
4
5
6
7
8
9
#remove reveal loader
$ scp -r Reveal.framework root@x.x.x.x:/System/Library/Frameworks
$ scp libReveal.dylib root@x.x.x.x:/Library/MobileSubstrate/DynamicLibraries
$ vim /Library/MobileSubstrate/DynamicLibraries/libReveal.plist
#input :{ Filter = { Bundles = ( "com.apple.MobileSMS"; "net.whatsapp.WhatsApp" ); }; }
$ killall SpringBoard

How to change status bar color

How to change Status Bar text color in iOS 7

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file.
  2. In the viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
  3. Add the following method:
1
2
3
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}

This will not work controllers inside UINavigationController

For anyone using a UINavigationController:

The UINavigationController does not forward on preferredStatusBarStyle calls to its child view controllers. Instead it manages its own state - as it should, it is drawing at the top of the screen where the status bar lives and so should be responsible for it. Therefor implementing preferredStatusBarStyle in your VCs within a nav controller will do nothing - they will never be called.

The trick is what the UINavigationController uses to decide what to return for UIStatusBarStyleDefault or UIStatusBarStyleLightContent. It bases this on it’s UINavigationBar.barStyle. The default (UIBarStyleDefault) results in the dark foreground UIStatusBarStyleDefault status bar. And UIBarStyleBlack will give a UIStatusBarStyleLightContent status bar.

If you want UIStatusBarStyleLightContent on a UINavigationController use:

1
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

Xcode 6 xcassets for universal image support

In 1x place image with resolution 320 x 480.

In 2x place image with resolution 640 x 960.

In Retina 4 2x place image with resolution 640 x 1136.

in 3x place image with resolution 1242 x 2208.

Images of Retina 4 2x will upscale to resolution 750 x 1334.

Images 3x will downscale to resolution 1080 x 1920.

http://stackoverflow.com/questions/26020979/xcode-6-xcassets-for-universal-image-support

##Size Class for launch image

  • 2x [- +] for iPhone6
  • 2x [- +] for iPhone4
  • 3x [- +] for iPhone6plus
  • Retina 4 2x [- +] for iPhone5