I have a UIBarButton that is connected, through the interface builder, to the following method:
- (void)btnJumpToStart_Touch:(id)sender {
index = 0;
[self setCurrentPage];
[self showCard];
}
index
is defined early in the implementation. setCurrentPage
is this:
- (void)setCurrentPage {
// I need to set the bottom page control first,
// this allows me to display that the user is viewing the
// first half of the deck or the second
if(index < 11) {
[self.bottomPageControl setCurrentPage:0];
}
else {
[self.bottomPageControl setCurrentPage:1];
}
// now we set the top page control. I use the index that is being displayed,
// then divided by whether or not the bottom page control is showing the
// first half, or the second
[self.topPageControl setCurrentPage:(index - ((deck.count / 2) * self.bottomPageControl.currentPage))];
// next I set the 'jump to end/jump to start' button's enabled properties
// the jump to end will only be anabled when the
// index is less than the deck's count - 1
if(index < ([deck count] - 1)) {
[self.btnJumpToEnd setEnabled:YES];
}
else {
[self.btnJumpToEnd setEnabled:NO];
}
// the jump to start will only be enabled when the
// index is greater than 0
if(index > 0) {
[[self btnJumpToStart] setEnabled:YES];
}
else {
[[self btnJumpToStart] setEnabled:NO];
}
}
Finally, showCard
is this:
- (void)showCard {
Card *card = [deck cardAtIndex:index];
[cardImage setImage:[UIImage imageNamed:card.imageFile]];
}
Now, as you can see, the btnJumpToStart
will be disabled, or enabled, in the setCurrentPage
method. it will start out as disabled (I set it as such in the IB). When the criteria is met to 'enable' the button, it doesn't work properly. The index
will be set to 0, but it won't set the current page properly, and the card is not shown. The weird thing is that after a few presses of the button, it might work.
Very intermittent...
Thanks for any help you can provide