Сообщения

Сообщения за 2016

Find out, what controller is on the top.

If you want to check, what controller is on the top right now, with this code all what you need is to minimize app and restore it again. And you will see an alert with the title of Controller. APPDELEGATE #import "UIViewController+Top.h" - (void)applicationWillEnterForeground:(UIApplication *)application { #ifdef DEBUG     NSString *topController = NSStringFromClass([[UIViewController topViewController] class]);     [[[UIAlertView alloc] initWithTitle:topController     message:nil     delegate:self     cancelButtonTitle:@"Ok" otherButtonTitles:nil] show]; #endif } CATEGORY @interface UIViewController (Top) + (UIViewController *)topViewController; @end #import "UIViewController+Top.h" @implementation UIViewController (Top) + (UIViewController *)topViewController { UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; return [rootViewController topVisibleViewController]; } - (UIVie

Xcode Swift Speed Up compilation

https://habrahabr.ru/post/317298/ //:configuration = Debug SWIFT_WHOLE_MODULE_OPTIMIZATION = YES http://stackoverflow.com/a/39477414/5790492 HEADERMAP_USES_VFS = YES http://stackoverflow.com/a/40580037/5790492 Unchecking "Find Implicit Dependencies" in Edit Scheme > "Scheme" > Build tab fixed it for me for project files. "Copy swift standard libraries" still takes forever.. http://stackoverflow.com/a/39864766/5790492 Not work, i think http://stackoverflow.com/a/40601731/5790492 Update  to Xcode 8.2

5/10/16 W

1) Xcode can run without build - Ctrl+Cmd+R 2) You can try pod example without cloning repo: pod try Google

Fr 05/09/16

1) How to start application in Xcode for different languages while testing.      In order to change default order of languages only for your XCode project, you can go to the Product > Scheme > Edit scheme, and add argument to "Run" scheme, for example: -AppleLanguages "(English,Russian)". 2) Go through all strings and take them to localizable.strings Type “cd ”, then drag in your project folder, then press enter to navigate to your project: find ./ -name "*.m" -print0 | xargs -0 genstrings -o en.lproj 3)  Git steps to create pull request Fork it! Create your feature branch:  git checkout -b my-new-feature Commit your changes:  git commit -am 'Add some feature' Push to the branch:  git push origin my-new-feature Submit a pull request :D

Mon 01/08/16

1) Disadvantage in using delegate of UITextField due to changing values in Cell's text fields.       If you have UITableView with UITextField in it's cells, you need to update it. There are some ways, and one of them to use UITextFieldDelegate like in example: func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { if string == " " { return false } let indexPathForCellWhereTextFieldIs = self.tableView.indexPathForCell(textField.superview?.superview as! UITableViewCell) if indexPathForCellWhereTextFieldIs != nil { textFieldValues[(indexPathForCellWhereTextFieldIs?.section)!] = (textField.text! as NSString).stringByReplacingCharactersInRange(range, withString: string) as NSString as String } return true } So you have to check if  indexPathForCellWhereTextFieldIs  is'n nil.

Wen 27/07/16

1) In viewWill/DidDisappear methods place code before [super ...].       - (void)viewWillDisappear:(BOOL)animated {     if ([self.navigationController.viewControllers indexOfObject:self] == NSNotFound)          {             [self.view.window endEditing:YES];              self.navigationController.toolbarHidden = YES;           }      [super viewWillDisappear:animated];  }

Tue 26/07/16

Изображение
1) How to select the row for default in UITableView.       First way in ViewDidLoad: //select first cell for default self.clearsSelectionOnViewWillAppear = NO; //if you use UITableViewController (delete if you use UIViewController NSIndexPath *indexPath = [NSIndexPath indexPathForRow:2 inSection:0]; [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];     Second modern way: tableView . remembersLastFocusedIndexPath = Yes ; - ( NSIndexPath *) indexPathForPreferredFocusedViewInTableView :( UITableView *) tableView From here . 2) How to use scrollView without ContentView     First of all select elements in .xib that you want to place at scrollView. Embed it in ScrollView from menu like at screen. Constrain ScrollView to UIView bounds. Constrain elements in ScrollView like you do it in regular UIView. (Maybe you have to use "Freeform" setting in Utilities editor for reasons of

Mon 07/26/16

1) How to change section header's titleLabel attributes.       From iOS 7.0 instead of using viewForHeaderInIndexPath... you can use - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {     UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;     header.textLabel.font = [UIFont fontWithName:@"Roboto" size:20];     header.textLabel.textAlignment = NSTextAlignmentCenter; }

Fr 07/22/16

1) How to convert NSInteger to String in modern Objective-C.       You can forget about  NSString *inStr = [NSString stringWithFormat: @"%ld", (long)month]; Use this: NSInteger value = x ; NSString * string = [@( value ) stringValue ]; Here @( value ) converts the given NSIntegert to NSNumber object from which you get the desired type . 2) How to  amazingly close keyboard without any code.      Here 3) Difference between search bar and search display controller.

Thr 07/21/16

Изображение
1) How to use a storyboard for single app controller. I met a problem when decided to use static cells. They can't be implemented in .xib files, but only in .storyboard. Due to get over this you should do next: Create storyboard file and UITableViewController in his workspace. Choose class and ID. Where class is a custom UITableViewController class and ID is custom string. In parent ViewController use this code: UIStoryboard *appSettingsStoryboard = [UIStoryboard storyboardWithName:@"NKVAppSettings" bundle:nil]; NKVSettingsTVC *appSettingsTVC = [appSettingsStoryboard instantiateViewControllerWithIdentifier:@"appSettingsID"]; [self.navigationController pushViewController:appSettingsTVC animated:YES]; 2) Invisible elements in UITableViewCells It's very interestin g, that when you use UITableViewCell class's elements (like  textLabel ) and Custom inherited  UITableViewCell's class elements. So you should or

Wen 07/20/16

Изображение
1) How to compare two folders in OSx. diff -rq '/firstFolderPath' '/secondFolderPath' In terminal; -rq means to search in subfolders and print short description. Example :  diff -rq '/Users/nikkov/Desktop/First' '/Users/ nikkov /Desktop/Second' 2) How to watch view hierarchy. NSLog(@"%@", [self.view recursiveDescription]); 3) How to exclude some files from compilation in Xcode. Target -> Build Settings -> Add User-Defined Setting -> Type "EXCLUDED_SOURCE_FILE_NAMES". In line's window type something like *.mm, *.h.

Tue 07/19/16

1) Xcode compilator revolution: Xcode 4: LLVM-GCC for default, but GCC still available. Xcode 4.2: LLVM 3.0 for default, GCC expropriated. Xcode 4.6: update to LLVM 4.2.  Xcode 5:  update to LLVM 5.0,  LLVM-GCC expropriated. GCC to LLVM transition completed. 2) How to integrate Unity into iOS app. https://github.com/armandsLa/ios-unity5-objc : Objective-C https://github.com/blitzagency/ios-unity5 : Swift https://github.com/keyv/iOSUnityVuforiaGuide https://bitbucket.org/jack_loverde/unity-5-vuforia-6-and-ios-native-integration 3) How send data between Unity and iOS app. http://alexanderwong.me/post/29861010648/call-objective-c-from-unity-call-unity-from Integration of Unity: 1) Скопировать папки Classes и Libraries (Create groups). Добавить Data (Create folder references); 2) Удалить ссылки на все .h в папке Classes/Native и удалить папку Libraries/libil2cpp (Remove references); 3) Изменить код в UnityAppController.h; inline UnityAppController* GetAppCont

Mon 07/18/16

1) subspec in podfile: s.subspec ' AFURL ' do | subspec | subspec.dependency ' ImageSlideshow/Core ' subspec.dependency ' AFNetworking ' , ' ~> 3.0 ' subspec.source_files = ' Pod/Classes/InputSources/AFURLSource.swift ' end s.subspec ' Alamofire ' do | subspec | subspec.dependency ' ImageSlideshow/Core ' subspec.dependency ' AlamofireImage ' , ' ~> 2.0 ' subspec.source_files = ' Pod/Classes/InputSources/AlamofireSource.swift ' end s.subspec ' SDWebImage ' do | subspec | subspec.dependency ' ImageSlideshow/Core ' subspec.dependency ' SDWebImage ' , ' ~> 3.8 ' subspec.source_files = ' Pod/Classes/InputSources/SDWebImageSource.swift ' end ---------------- 2)  Only necessary in Pod: pod 'ImageSlideshow/SDWebImage', :git => ' https://github.com/zvonicek/ ImageSlideshow.git ' 3) Parting by conditions.