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


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 convenience.
  • AND THE MAGIC: select any view that have constraints from left and right and make a constraint "Align X". It will make scroll view fit your screen after build.
3) Blocks to transfer settings to already existed View Controller from Modally presented View Controller
     Very very cool.

  • In controller A (root)
ModalController *filterController = [ModalController new]; __weak typeof(self) weakSelf = self; filterController.selectionCallback = ^(NSUInteger selectedItem) {
weakSelf.topicID = selectedItem; [weakSelf.tableView reload Data]; }; [self presentViewController:filterController animated:YES completion:nil];


  • In controller B (modally)
typedef void(^CallbackBlock)(NSUInteger value);
//Interface@property (nonatomic, copy) CallbackBlock selectionCallback;
//Implementation- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if (self.selectionCallback)
{ if (indexPath.row == 0)
self.selectionCallback(0);} [self dismissViewControllerAnimated:YES completion:nil];}
4) Important notes if UIActivityViewController takes long to load.
    From this topic you can find how to implement a nice bar activity indicator, remove UIActivityTypeAirDrop to make it load faster.






Комментарии

Популярные сообщения из этого блога

Xcode Source Extensions Setup

Find out, what controller is on the top.

Xcode Swift Speed Up compilation