Apples keyboard appears then scroll code sample does not work correctly - objective-c

I have a UITableView with a navigation bar on top. I have several text fields in the cells and if i click in the cell at the bottom the keyboard hides the text field. So I googled and found this link: http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW7
I used exactly that code and run my app again. Now it scrolls up (about the height of the keyboard) instead of scrolling down. Also it scrolls in every cell, even the cells at the top which will not get hided by the keyboard. Does anyone have a solution for this? I tried to log out some coordinates inside the keyWasShown: method but it's very complex for me to figure it out.

So I used trial and error and finally found out, that I have to add two superview properties behind activeField:
activeField.superview.superview.frame.origin
Do this behind every activeField in the method keyboardWasShown: and it will work. Ah and I added 70 pixels, because the view didn't scroll exactly where I wanted it to, maybe it is because of the navigation bar I use, I don't know:
activeField.superview.superview.frame.origin.y - kbSize.height + 70

Related

Xcode UITextView Still not scrolling using storyboard

I am trying to initiate a scroll view in my UITextView and even though I seem to have selected the appropriate boxes, I can't seem to get the scrolling working. I have gone through multiple questions similar to this but none seem to have the answer.
I included an image of Xcode below:
Question 2: When I scroll down the majority of my text shows but the scrolling stops with two sentences or so left and I have to scroll down and hold it there to read. Any way I can fix this so it scrolls all the way to the bottom of the text?
Can you check the two boxes: Bounce Horizontally and Bounce Vertically and see what's happening? Sometimes your content are actually way bigger than your view, and they are touching a invisible outer box. If you can see they actually move, that means there is nothing wrong with touch or scroll, is just the view layout problem.
For the content issue, my guess is that the content size is not right, you can programmatically adjust it with textView.frame property, set it to a proper size, such as the frame of the window or the frame of the content, which are CGRect classes. Comment below to see if this can solve your second problem.
The text view will not scroll in storyboard, only the app. And the text view will scroll once the content in the text view exceeds the frame size.
If you're using iOS 7+, you can just turn on auto layout, pin each of the sides of the text view to the edge of its parent view, and it works fine without needing to do anything in code.

NSPopUpButton in NSToolbar such annoying

Problem solved!:
Just check the "Unified Title And Toolbar" option of the NSWindow and the 1pixel-down problem goes away!
To change the toolbar height just select the Toolbar Item - Custom View and change size in the Size inspector.
==============================
If you know Xcode 5s layout than you should recognise this:
I want to build it for my own. So I dragged a Toolbar in the Window and added a NSPopUpButton. Then I changed the PopUp Button Cell Style to Radio and turned off the Arrows. So far so good.
The first thing I noticed is that the Toolbars has different heights. Does anybody know how to change this behaviour (without subclassing NSToolbar)?
The second and more annoying thing I noticed is that if I choose an Item from the PopUp Button the Image for the NSMenuItem move 1 pixel down.
EDIT: Xcode NSMenuItems don't move 1pixel down
Any suggestions about that thing?
NSToolbar, sadly, can’t really be subclassed. It’s a poorly-written class that tries to be very “magic,” so it’s not even a subclass of NSView—you can’t control how it draws at all, it creates a private view.
You can set its “sizeMode” but I assume you’ve already done that and found that the number of pixels high isn’t what you want.
The easiest thing to do is just leave space for your widgets at the top of your window (above the document content) and have autolayout position your buttons for you. (I haven’t been able to use a real NSToolbar in years because of its limitations.)
As for the popUp menu being mis-aligned with the button: where the menu draws is basically hard-coded, so if you use a button style that NSPopUpButton doesn't expect then the menu will be offset some.
If you’ve already tried just unchecking the “draws border” flag on a default-style NSPopUpButton (one fresh off the palette), There are two solutions for to try: One is to keep trying different buttonStyles that look correct to your eye until you find one that’s not offset. Two is to leave the buttonStyle do the default for NSPopUpButtons but subclass the buttonCell and have it not draw the border (but still leave room for it).

How to add empty cells in UITableView without expanding it

I have UITableView with custom looking cells. Now user can scroll past the bottom and see that there are no more rows (cells) and see background. I want to create impression that there are more rows below, but they should not be added to tableview, so when user scrolls down, it bounces back to last useful cell.
TableFooter and subview expands content and user can scroll there (or maybe I was doing it wrong).
Right now I added new empty cells and after any action that may recount contentSize I specifically set contentSize to default setting. But I feel like it's not the right way (although it works). Is there some other way?
I tried searching, but it's hard to explain what I want in few sentences, not to mention in search line.

Resetting the selection cursor in a UITextView

I've looked at similarly titled questions, such as :
UITextView disabling text selection
but that wasn't quite what I was trying to achieve.
My app has a UITextView that only requires vertical scrolling. When holding down a touch, the cursor obviously appears at the point of the touch. However, when I change the text of the view, the cursor is always put at the end of the UITextView, which of course scrolls my text all the way to the bottom. I've tried setting the selected range, but even with the editable set to NO, this causes the keyboard to popup. I want my view to be able to display my text and vertically scroll, and to be able to reset its scroll position when I change the text. If I could achieve this and not be able to select, copy, paste, edit, etc. I would be perfectly content.
The last time I tried to deal with this I gave up and ended up using a UILabel, however I need to be able to scroll this time around. Would I be better off putting a UILabel inside a scroll view as a work around? Or perhaps releasing the textView would work, but since I have it hooked as a referencing outlet in IB, I imagine I would have to recreate it programmatically, and I'd like to avoid something so hacky if I can.
I'm at my whit's end with something I've always felt should be simple, so thanks in advance for any and all help!

Possible bug in Interface Builder?

I've a window with a horizontal split view. On the bottom pane of the split view, I have a nssegmentedcontrol, aligned to the center. On the bottom of the nssegmentedcontrol I have 5 tabs that are controlled by the segmented control - click in one of the cells and the corresponding tab opens.
My problem is, if I completely minimize the bottom pane, to the point where the dividing line touches the bottom of the window, the segmented control gets pushed on top of the table header and never goes back to its original place.
I've tried fiddling with IB to get this to work, but no luck. Has anyone experienced this?
Following what's on the comments, I replaced the default split view with the one found in BWToolkit that allows for the definition of minimum and maximum height of each view.
BWTookit is a no go, the framework leakes a lot.
You should use RBSplitView (google it), it also gives you option for min and max height
and I started using it because of a bug in the split view as well, I used it for a chat window
but the split view didn't autosave as it should, every time it got like 2px smaller,
RBSplitView is great, and doesn't leak.