UITableView didSelectRowAtIndexPath: not being called on first tap
Any chance you accidentally typed didDeselectRowAtIndexPath?
Any chance you accidentally typed didDeselectRowAtIndexPath?
For iOS 6 and above, use the following to allow multiple lines: button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; // you probably want to center it button.titleLabel.textAlignment = NSTextAlignmentCenter; // if you want to [button setTitle: @”Line1\nLine2″ forState: UIControlStateNormal]; For iOS 5 and below use the following to allow multiple lines: button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; // you probably want to … Read more
You’ll need to add an UITapGestureRecogniser and assign it to the view, and then call resign first responder on the UITextField on it’s selector. The code: In viewDidLoad UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; [self.view addGestureRecognizer:tap]; In dismissKeyboard: -(void)dismissKeyboard { [aTextField resignFirstResponder]; } (Where aTextField is the textfield that is responsible for the keyboard) … Read more
How can one get the dimensions of the screen in iOS? The problem with the code that you posted is that you’re counting on the view size to match that of the screen, and as you’ve seen that’s not always the case. If you need the screen size, you should look at the object that … Read more
For iOS 7.0, I’ve found that the contentInset trick no longer works. This is the code I used to get rid of the margin/padding in iOS 7. This brings the left edge of the text to the left edge of the container: textView.textContainer.lineFragmentPadding = 0 This causes the top of the text to align with … Read more
This works for both iOS 6.1 and iOS 7: – (void)textViewDidChange:(UITextView *)textView { CGFloat fixedWidth = textView.frame.size.width; CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)]; CGRect newFrame = textView.frame; newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height); textView.frame = newFrame; } Or in Swift (Works with Swift 4.1 in iOS 11) let fixedWidth = textView.frame.size.width let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, … Read more
During startup in (-viewDidLoad or in storyboard) do: self.tableView.allowsMultipleSelectionDuringEditing = false Override to support conditional editing of the table view. This only needs to be implemented if you are going to be returning NO for some items. By default, all items are editable. – (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return YES if you want … Read more
There’s no way to set the vertical-align on a UILabel, but you can get the same effect by changing the label’s frame. I’ve made my labels orange so you can see clearly what’s happening. Here’s the quick and easy way to do this: [myLabel sizeToFit]; If you have a label with longer text that will … Read more