This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *)getWordAtPosition:(CGPoint)pos inTextView:(UITextView*)_tv | |
{ | |
UITextView *tempTextview = [[UITextView alloc]init]; | |
tempTextview.text = temmp; | |
//eliminate scroll offset | |
pos.y += _tv.contentOffset.y; | |
//get location in text from textposition at point | |
UITextPosition *tapPos = [_tv closestPositionToPoint:pos]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = "X yz" | |
for var i = 0; i < s.characters.count; i++ { | |
let x = s[s.startIndex.advancedBy(i)] | |
print(x) | |
print(String(x) == " ") | |
} | |
for c in s.characters { | |
print(c) | |
print(String(c) == " ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>Blank Loader</title></head><body><div class=\"outer_container\"><div class=\"loader\"></div></div><style>html, body { margin:0; padding:0;background:rgba(0,0,0,0);}.outer_container { background:rgba(0,0,0,0);width:100%;overflow:hidden; position:relative}.loader {width: 90px;height: 2.5px;background: #2b2b2b;box-shadow: 0 0 80px 60px #000;animation: load 1.0s infinite;transition:all 1.0s ease-in-out;margin-left:0;}@keyframes load {0% {margin-left:-200px;}100% { margin-lefT:120%}}</style></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGFloat)heightForAttributedString:(NSAttributedString *)text maxWidth:(CGFloat)maxWidth { | |
if ([text isKindOfClass:[NSString class]] && !text.length) { | |
// no text means no height | |
return 0; | |
} | |
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading; | |
CGSize size = [text boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:options context:nil].size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Could not find Developer Disk Image : | |
I personally downloaded Xcode 6.4 beta and 7.0 beta and I was very happy to find the solution by searching "8.4" inside the application folder of the 6.4 beta. By doing this, I found the folder 8.4 (12H4125a) containing the iOS 8.4 image and I copied this folder to the same path of the 7.0 beta. The path is the following: | |
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
When you will reopen Xcode 7 and choose your device, there will be an error message; just click on fix issue and that should do it! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)writeStringToFile:(NSString*)aString { | |
// Build the path, and create if needed. | |
NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | |
NSString* fileName = @"bookmark.json"; | |
NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName]; | |
if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) { | |
[[NSFileManager defaultManager] createFileAtPath:fileAtPath contents:nil attributes:nil]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Subclass UITextfield and Override the - (CGRect)caretRectForPosition:(UITextPosition *)position //method and return CGRectZero. | |
- (CGRect)caretRectForPosition:(UITextPosition *)position { | |
return CGRectZero; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UILabel (dynamicSizeMe) | |
-(float)resizeToFit; | |
-(float)expectedHeight; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL) isValidEmail:(NSString *)checkString | |
{ | |
BOOL stricterFilter = NO; | |
NSString *stricterFilterString = @"^[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$"; | |
NSString *laxString = @"^.+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*$"; | |
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:checkString]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { | |
let textfieldPos = scrollView.convert(textField.frame.origin, to: view).y | |
let textFieldHght = textField.frame.size.height | |
let scrollViewHght = scrollView.frame.size.height | |
if (textfieldPos + textFieldHght) > (scrollViewHght - 250) { | |
var duration : Double | |
if isKeyBoardVisible { |
OlderNewer