I'm using iCarousel in my Swift+Sprite Kit game, where the user has unlocked and locked items.
The locked items would display some info like current user coins, and some text that says "UNLOCK THIS FOR: X amount of coins", if the carousel item isn't locked, it won't display any of that information, just a button that says "Select".
Now, I got that working, but it will only work when i start swiping the items and not the first time the carousel shows up.
To make that work, I do it inside carouselCurrentItemIndexDidChange() method. And that obviously changes when I swipe.
How can I set the current carousel index at start so then I can force to show or not show the information depending if the item is locked or unlocked and not only when I start swiping?
To add more information about this, imagine that the user selected the item at index 4, i save that index locally. So if the user closes and opens the game, the carousel should begin at 4 not 0.
Thanks in advance.
You should set up your carousel views in viewForItemAtIndex: reusingView:. The view returned by this method should represent the current state of that carousel item; so locked or "Select" as appropriate.
If the state of an item changes then you can call reloadItemAtIndex: to have iCarousel request an updated view for that item by calling viewForItemAtIndex: reusingView:.
You can scroll the carousel to a particular item by calling scrollToItemAtIndex:animated:
Related
Two sections are being generated. CarPlay automatically generates them using the data we provide from the MPPlayableContentDataSource. How can I detect when a user taps on a tab?
There is an API called beginLoadingChildItemsAtIndexPath in MPPlayableContentDataSource. You can use indexPath.length and [indexPath indexAtPosition:] to make sure which item is taped ( include tab-item )
In short: You can't. You can use the methods called on MPlayableContentDataSource (first time the tab is visible the items for that tab will be queried) and MPPlayableContentDelegate (when the user taps on an item, it's clear which tab the index path belongs to) to reason about the currently visible tab, but there is no public method that is called upon switching tabs.
I'd like to run a procedure--once--whenever the selected item in a ListView changes. The obvious choice would be OnSelectItem, but it's called twice when the user moves from one selected item to another (using mouse or arrow keys). Similarly, OnChange is called three times when moving between items.
Is there an event generated only once under these conditions? OnClick is generated once, but doesn't cover moving between items using arrow keys, etc.
You can do it like this using OnSelectItem.
Remember the last selected item.
When the OnSelectItem fires, check if the current selected item differs from the one you remembered.
If so, perform your task, and make a note of the new selected item.
MPMediaPickerController used to give a visual indication that an item was selected prior to iOS 8.4.
In 8.4 when a picker is displayed and allowsPickingMultipleItems is set to true, it does show that items are selected in mediaPicker:didPickMediaItems but while picking, selected items simply highlight (sometimes) but then just flip back to a normal display without highlighting the + indicator.
Prior to iOS 8.4, when selecting multiple items using MPMediaPickerController the selected items remained highlighted to indicate selection. Additionally, it was not possible to select an item multiple times.
As of iOS 8.4, selecting an item simply highlights it for a brief period of time and the user can select the same item multiple times without being aware that she has already selected the item.
Steps to Reproduce:
1. Implement an instance of MPMediaPickerController (init with MPMediaTypeMusic)
2. Set "allowsPickingMultipleItems" to "YES"
3. Present the controller modally and try selecting an item
Expected Results:
Selected item should remain highlighted to indicate selection and it should not be possible to select an item multiple times
Actual Results:
Selected items are not reflected (aside from a brief highlight - dehighlight) and it's possible to select an item multiple times mistakenly.
I was able to fix this issue by remaking the MediaPickerController every time I wanted to use it.
I used to keep it around in the global scope to prevent having to remake it every time the user wanted to pick something.
Now when I select a song or an album the checkmark always shows up, so it is fixed.
It used to be that selecting songs or albums on the second presentation of the same MediaPickerController didn't show a checkmark when the user selected a song, however it would select the song anyway.
In the TListView control, you can edit an item by clicking on it twice. A box appears around the item for user to type in a new value. How can I enable edit mode programmatically? I would like to protect the list from accidental editing, and disable editing (by enabling the ReadOnly property). Then, when the user presses an Edit button, the item will become active to edit. How can I do this?
Also, if suppose the user selects an item, then scrolls out of that item's view, then presses Edit, the list needs to first scroll to make that item visible.
After setting ReadOnly to false you can call the EditCaption method. Call MakeVisible to scroll the item in view.
ListView1.Items[0].MakeVisible(False);
ListView1.items[0].EditCaption;
I'm starting with jQuery mobile and have some problems with my buttons.
The web application is a shopping list. It displays a list of items to shop and in the footer buttons on actions I can perform on the items.
The actions are:
increment number of items to buy
decrements number of items to buy
move item up in list
move item down in list
add new item
delete item
modify item text description
The actions are implemented in javascript and works fine. The problems I have is with controlling the buttons and the associated actions.
By experience, I have see that for the increment and decrement it is more convenient to have a button with an active state, for the other operations it is preferable to have a selected item and apply the action on the selected item when the button is pressed. When adding an item, the item would be inserted before the selected item, and if pressed when no item is selected, the new item is appended to the list.
I would also like to have 2 modes. In one mode, only the increment and decrement buttons are shown and the user can update the number of items in its list. In the other mode the user is modifying its list. It is in the second mode that the selected item is required.
I managed to associate a default action my item lists by using the .on() method as a delegate.
$('#itemList').on( "click", ".item", function(evt)
{ ctrl.doAction($(evt.currentTarget)); });
Here is the html code I use to test the first mode.
<!-- footer -->
<div data-role="footer" data-position="fixed" class="ui-bar" id="btnBar" >
Plus
Minus
</div>
<!-- /footer -->
What should I put as href value ? I don't want the page to be reloaded. In some examples I see "#".
This is how I associate the action to the button:
$('#btnPlus').on( "tap", function(evt)
{ ctrl.doAction = ctrl.increment; });
Another problem I have is that there is no feedback on the button click action. When I click a button I would expect to have it highlighted for a short time. This doesn't happen.
The browsers have also different behaviors. In firefox, the clicked button gets a blue halo apparently showing that it has the focus. But the button isn't displayed as active.
If I put "#!" as href (don't know what it means) on Android, the clicked button is shown active.
Should I use click or tap as event type ? How could I write click or tap ?
How could I implement a two state button displayed as active and inactive ?
How is an action button used : always displayed inactive and feedback when pressed ?
I solved the problem my self.
to switch between sets of buttons in the footer, I create multiple footers in my HTML document with style="display:none" in the hidden footers. The one without this will be shown. I assigned a specific id to each footer so that I can write $("#footer1").hide(); $("#footer2").show();
I have buttons to switch between footers. The footer switching event handler must be called with the "mouseup" event. This is required for it to work on the iPad and Android phones.
To change appearance, don't use .button() as suggested here. Use:
$("#myButton")
.removeClass( "ui-btn-up-a ui-btn-down-a ui-btn-hover-a" )
.addClass("ui-btn-up-b")
.attr( "data-theme", "b" );
Note: There was a bug in my code which caused desperate hair pulling