WatchKit Interface controller scrolls too much after adding next page segue - objective-c

experts!
Today started to build Apple Watch version for my CelebrateMore! app and can't solve one issue. I have 2 interface controllers - Page-based kind. As soon as I set segue to "next page" from first to second, my first interface controller starts to scroll much more than before.
Screenshot from Storyboard:
Screenshot from simulator during scrolling:
Screenshot from simulator if I remove next page segue and scroll:
Already from scrollbar it can be seen, that there is a lot of empty content if "next page" is used. Does anyone has some idea, how to solve this, how to avoid "the long after content scrolling" issue?

I've struggled with the same issue for several hours until I decided to give it up for a while and focus on filling the labels with actual data at runtime. After I added some code to the main initialisation methods of WKInterfaceController ((void)awakeWithContext:(id)context {} and/or (void)willActivate {} ), this scrolling issue magically disappeared. Try to set the text of one or all the labels in your interface in code in one of the 2 methods mentioned above and see if the scrolling problem gets fixed:
[self.label setText:#"Some text.."];
It worked in my case.

Due to low reputation I cannot upvote: The solution of setting the text of a label worked for me too. I set an empty text first, then load the data and update the label there again once the request is successful. It works and calculates the height of the scroll view correctly.
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
//enable correct scroll height
self.titleLabel.setText("")
self.loadData()
}

I used a different way to work around it.
First put a group in the InterfaceController, and assign fixed height to it, then put other components inside the group.
To make the group occupy full screen, its height for 38mm should be set to about 142 point and for 42mm should be set to about 165 point. You can use the plus sign next to the value to enter these values for the 2 models.

Related

Widget Simulator does not display elements of "Today Extension”

I want to implement the “Today Extension” feature into one of my applications. I successfully added the extension, gave it a run and saw the “Hello World” screen on the simulator. I then deleted the "Hello World” label, and added my own labels to the view. Nothing spectacular and really nothing I thought which would make me any trouble…
Now when I run the widget all I get is an empty Simulator:
Things I tried:
Checked that "File’s Owner" has the view connected
Coloured the labels and made sure they aren’t hidden
Checked if the view’s controller gets initialised accordingly
Fiddled around with Autolayout: The extension view does look like a (too) small bar compared to the size I assigned. The strange thing is, that even if I drag one label to the top, it does not appear
Tried a “Clean” and “Clean Build Folder” and also “Clear Snapshot” in the simulator
Downloaded a working today extension from Github to check if I did something wrong. Couldn’t find anything.
It does seem like I’m working on the wrong view. But it is in fact the same view which displayed me the “Hello Word” label. Am I missing something? (#Moderator: I suggest adding the following tags: osx-today-widget, widget-simulator. Thanks in advance.)
Without the code it is hard to say, but maybe this helps:
what text color does your label have?
make sure to give it "Control text color"
what is your minimum height>
click the "Custom view" in your xib file (the root view) and click Editor > Pin > Height.
Set it to 200 and "greater or equal than"

First segment of my segment controller doesn't respond

I have a settings screen with a couple of segmented controls on it. All was well until I added a third. Now the new one works, and the top one works, but the one in the middle doesn't...
It used to work fine, but now the first segment doesn't respond. If I click on segments 2 through 4 my controller's method is called as expected. If I click on the first segment... nothing.
I suspect there is another flag somewhere that I hit by mistake, but I can't find it. Yes, all of the segments are Enabled. Any ideas?
I would suggest looking through the hierarchy in detail: the tap is possibly trapped by a partially overlapping view.
If a tap does not respond because the size of an element changes, it may because it is hidden by one of these:
an unconventionally long navigation item
a view with no visible content
a title view
This amazing tool has saved me time and again: Spark Inspector. It shows you the intricate overlapping layers of all your UIViews.

UISwitch not responsive in UIScrollView

I'v encountered strange bug, and have no idea why this happens.
I have UIScrollView, in it I have 12 views. Most of them contain UISwitch button and a label. Size of views are dynamic (depending on the lenght of label.text). Everything works and shows, except two views on the bottom. They do get shown, initialize as expected. Yet UISwitches in them do not work, clicking or touching them does not do anything. Both of them are no exception to others (all of them are copy paste). I have double checked IBOutlets, they are fine. I have suspicion something is wrong with scrollView. Maybe beyond some point it doesn't recieve inputs anymore? Eventhough I can scroll up and down and everything is shown just as expected.
Any ideas what to check ?
I have switched these two views with first ones. And more bottom views get unresponsive, like there is a line, beyond which ui is not responsive. Ideas?
You say the switch is in a view (one of 12) and that view is on the scroll view,
maybe the UISwitch is out of the view bounds? Try to set that views .clipsToBounds = YES;, can you still see the switch? If no, it means the switch is out of bounds therefor you gat no touch events. Make that view larger to fix that.
Check correctly. if the UISwitch and UIscrollview user interaction are enabled.
Check whether the UISwitch is added within the UIscrollview's frame.

Apples keyboard appears then scroll code sample does not work correctly

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

UIPageControl - Lonely indicator is visible, although hidesForSinglePage is true

Although I've set hidesForSinglePage to true, the lonely indicator is still visible. But not where the indicators normally are, but in the upper left corner (?!) of the page control. It's like it trying to hide by stepping aside, but fails by taking a few steps too little. I've been playing with all kinds of attributes, but none has even tweaked this strange behavior.
Does anyone have any clever clues?
Thanks,
Johannes
I discovered when this bug came to life, and thus come up with a solution. I had set the number of pages of my page control to 1 in Interface Builder. When I changed this to a greater number, and then let my code set it back to 1 when the NIB had been loaded, the bug disappeared.
Very strange indeed...
I got the same problem with new XCode 5 and iOS7. I didn't set up the UIPageControl via IB or Storyboard but within code. The problem occured because I had set somePageControl.hidden = FALSE; after I set the pageCount = 1. When I set hidden = TRUE before setting pageCount the single indicator disappears.