Posts

Showing posts from 2015

UITableView with Keyboard handling for UITextFields

UITableView has its parent class as UIScrollView. So, if you have a UITableViewCell , which has UITextField, then it needs to handle the contentOffset. More details on contentOffset  ( another url )and keyboard handling   in iOS. Lets say if we want to add a bottom inset of 216 (approx. kyeboard height). the following would be the code You basically change the content Offset while the content size remains the same. self.contentOffset = UIEdgeInset(0,0,216,0). This will move the content ( in the UITableView) up by 216. The below code also handles autosuggestion bar ,  as the autosuggestion delta (approx. 29) gets added to existing delta. And Removes it accordingly. -( void )viewWillAppear:( BOOL )animated{     [ super viewWillAppear :animated];     [ self   registerNotifications: YES ]; } -( void )viewWillDisappear:( BOOL )animated{     [ super viewWillDisappear :animated];     [ self   registerNotifications: NO ]; } -( void )registerNotifications:(

Change height of the UISegmentedControl

Image
UISegmentedControl changing height is sometimes difficult to find. It can be easily done if you are using constraints. In case if you don't use constraints , I tried the following approach which I though would work, but actually it did not. - ( void )viewDidLoad {     [ super viewDidLoad ];      CGRect rect= self . seg_cntrl . frame ;     rect. size . height =60.0;     [ self . mySegmentControl setFrame :rect]; } Later on I found if you try to create a UISegmentedControl object using a code and then set the Frame it  will consider the height that you set. - ( void )viewDidLoad {     [ super viewDidLoad ];          UISegmentedControl *seg=[[ UISegmentedControl alloc ] initWithItems :@[ @"1" , @"2" ]]     ;     [seg setFrame : CGRectMake (25.0, 70.0, 300.0, 60.0)];     [ self . view addSubview :seg]; } The result can be seen in the following image.