Erratic UIPageControls - iphone

I'm using two UIPageControls in a view to reflect chapters and pages. So I have defined one UIPageControl named chapterCount and one named pageCount just to show where the user is. I handle the flipping of the pages with swipes rather than using the UIPageControls (so no methods defined for them).
I change their values as the user change pages with the following code:
chapterCount.numberOfPages = chapters;
chapterCount.currentPage = chapterNumber;
pageCount.numberOfPages = pages;
pageCount.currentPage = pageNumber;
[chapterCount updateCurrentPageDisplay];
[pageCount updateCurrentPageDisplay];
Where chapters, chapterNumber, pages and pageNumber all are integers.
The first time I flip through the pages it normally works fine, but when I go to a previous chapter or start a new chapter, the first (or last depending on direction) dot is not showed. Please see picture (upper half is missing a dot, lower one OK).
alt text http://img80.imageshack.us/img80/3339/pagecontrol.png
Its the same code updating the controls and sometime I get a dot, sometimes not. When I check the variables with NSLOG they are correct (eg the same for both pictures above).
I have checked Apple's documentation and tried their example but no luck.
Where should I start troubleshooting? I'm getting crazy!!

I finally found the problem :-)
An UIPageControl that is given a value 0 for number of pages will not show correctly the next time it is updated. I was reading chapter and page numbers from an array and in the beginning (let's say cover of the book) there are no pages and no chapters to show, so I happily set these to 0. Since I did not want to change the source data in my array I used MAX(pages , 1) for numberOfPages, so now it's working like clockwork.

Are you sure your chapterCount and pageCount views are not nil? You can have valid values all day, a message to nil does nothing and returns nil. Double check your view and controller wiring/unwiring when you change chapters.
EDIT:
confirm the size of the control is big enough to hold all your pages, and the view bounds is not clipped. For example, if you had 10 pages, and the "current" page was 10, but there were only 9 dots visible, it would appear as though nothing is highlighted because the white dot would be clipped from the visible area by being outside the viewable bounds. You can adjust the size dynamically using this:
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount

Related

VS Code brings search result line to the center of the screen

When you search for a keyword in VS Code, and it returns x results, as you start browsing among those results, the screen always centers vertically the active result on the screen. This may be useful in some situations, but in cases where I want to "frame" all my results in the same active screen, it's very annoying that it jumps the code, even by 2-3 lines...
OK, if in that viewable portion of the code there are no results, and I click on the next result, it'd make sense to bring me to the first one. But if let's say 4-5 results are already in the viewable portion of the code, I would like to set it so that it prevents that centering all the time. So is there such a setting?
I hope I explained it well enough so that you understand what I mean. TIA for any help.
I don't think that is configurable if the next find match is outside of the viewport. I see this in the code:
(https://github.com/microsoft/vscode/blob/7a0a293b38c353cd9773316a022d8f926d481715/src/vs/editor/contrib/find/browser/findModel.ts)
private _setCurrentFindMatch(match: Range): void {
let matchesPosition = this._decorations.setCurrentFindMatch(match);
this._state.changeMatchInfo(
matchesPosition,
this._decorations.getCount(),
match
);
this._editor.setSelection(match);
this._editor.revealRangeInCenterIfOutsideViewport(match, ScrollType.Smooth);
}
So revealRangeInCenterIfOutsideViewport() will always put the next find match into the center if it is not initially not in the viewport.
In the search code, there is the similar:
this.searchResultEditor.revealLineInCenterIfOutsideViewport(matchRange.startLineNumber);
So I would think there is no scrolling if the next serach result is already in view.
For me, there is no scrolliing at all if the next find match is anywhere in the viewport. Do you see some scrolling if it is at the very bottom, for example?

iText7 How do I know Table flows to next page like ITextshap Column.HasMoretext?

I have a form where I have to place some fixed data on top and bottom with a variable table in between. If table does not fit on first page, there should be created more pages as needed to acomodate Table.
But for page 2, 3, 4... I still have to print top & bottom, but this time a short version of whats was placed on page 1.
In ItextSharp5 with ColumnText.HasMoreText = true, I know when a new page is needed and can make a new page with proper top & bottom data before drop remaining table.
So how can I achieve same behaviour with iText7?
I did not found a way to know when a table needs some more room
After some reading, found a starting point at Chapter 2: Adding content to a Canvas or a Document
on 3th block of code.

How To Position a Picture on A Second Page Of A Word Document VB6

I am making a program that repeatedly creates pages of an undefined quantity, and on the top of all the pages is a logo that is in a certain position. If I have everything in a for loop and at the end I include these commands to make a page break:
Set oRng = oDoc.Bookmarks("\EndOfDoc").Range
oRng.InsertBreak
The second time (and subsequent times) the table I make goes on the the next page, but the image does not. I have tried setting the "top" property to
distFromTop + pageLength * pageNumber.
I would assume it might have to do with the anchor property, but I have no idea what data type that even gets or how it affects the placement
I insert the image using:
oDoc.Shapes.AddPicture "C:\Users\name\Desktop\file.jpg", , , CentimetersToPoints(1.3), CentimetersToPoints(0.9 + pageLength * j), CentimetersToPoints(6.1), CentimetersToPoints(2.9)
The picture adds multiple times, but both to .9 from the top on the first page and 1.3 from the left, on the first page.
How can I make the pic go .9 from the top of a certain page
EDIT: I would like to avoid putting it in a header because that would mess up the alignment of the other elements of the doc
Ok, So what worked for me was this:
Set oRng = oDoc.Bookmarks("\EndOfDoc").Range
oRng.InsertBreak
oDoc.Shapes.AddPicture "C:\Users\me\Desktop\file.jpg", , , CentimetersToPoints(1.3),
CentimetersToPoints(0.9), CentimetersToPoints(6.1), CentimetersToPoints(2.9),
oDoc.Bookmarks("\EndOfDoc").Range
I still don't quite understand why it works, because the documentation for a range objects / anchors was fairly hard for me to understand... I tried this out and this worked. For my purposes that worked, but if anyone knows why that works I would love to know
Thanks for your answers

GWT SimplePager issues

I am using GWT's (2.5) SimplePager class in my application, to display pre-loaded data (I know the exact row count in advance).
The issue is with the last page. Given I have, for instance, 42 elements with an initial visible range of 10.
First page is 1-10, second 11-20, third 21-30, fourth, 31-40.
The issue is that fifth page is not 41-42 (which I want, because I want to be able to scroll back and forth and "land" exactly on the same data) but 33-42.
I have tried various tinkering with overriding SimplePager / AbstractPager methods, with no success.
For instance, if I override setPageStart, do the same as com.google.gwt.user.cellview.client.AbstractPager.setPageStart(int) but with the following commented out (I think it is the culprit code):
if (isRangeLimited && display.isRowCountExact()) {
index = Math.min(index, display.getRowCount() - pageSize);
}
The last page is fine (41-42), but this erases page size forever and when I go from last page to previous page, it becomes 40-41 (expected: 31-40). This is probably because the page size is not some constant provided to the pager instance, but is calculated with the Range object which was last used ("int pageSize = range.getLength();" in setPageStart method).
Any clue on modifying the paging behavior to my needs without breaking anything ?
Thanks !
I eventually got a working solution which is simple enough.
I provided a page size (which is the maximum number of elements that could be displayed, regardless of the total number of elements available to display) to my SimplePager object. Then I overrided getPage(), hasNextPage(), hasNextPages(int), hasPreviousPages(int), nextPage(), previousPage(), setPageStart(int) to use the provided page size instead of getLength() on the Range object.
To test this more easily (still done by hand...) I used GWT's Showcase project (and ran it in dev mode).
The downside is that I had to copy the code of the overriden methods (from AbstractPager - SimplePager does nothing except calling the superclass' methods) into my Pager class.

Any way to find double current pages in turn.js?

My requirement is to display the current double pages in following format:-
2-3
4-5
and I only done with displaying singe page at a time however there is a double page view.
like
2 at 2-3
4 at 4-5
Any idea how do I fetch these current double pages in expected format?
I know I can do it by using adding logic, but would be better if I do it with internal logic of turnjs.
because It can be happen only single page comes sometimes like cover page or last page. I am sure there must be a way to find by turnjs only.
Any help will be appreciated...
Thanks in Advance.
I found its solution.. There is an array with the name view that holds the page's numbers to display. If there is a page 1 it holds the value
view[0] =1
View [1]=0
Similarly if its a last page lets say page 12 then the value in view will be
View [0]=0
View [1]=12
And if we are at 4-5 pages then
View [0]=4
View [1]=5
Got the solution :)
To be more specific here you can use this property.
view
Eg.
var view = $("#flipbook").turn("view").join(" - ");
alert("Current view: "+view);
It will return like this.
0 - 1
2 - 3
.......
Read here: http://www.turnjs.com/docs/Property:_view