Set UIPicker in motion like a slot machine after a button pressed - ios

I'm very new to objective-c and IOS development. I want to create a very simple slot-machine app. For that I used an UIPicker and filled it with the required data. However I'm having trouble to make it roll after the user clicks a button. I don't have any idea how to implement that kind of movement.
Can anyone give me a direction? I don't have any code to add because everything is displayed like it should, except that method to make the picker actually move which I don't know how to implement at all.

You can accomplish this by loop in animating to a specific row , so create a timer that fires every 1 second inside it increment row / component put this
[picker selectRow:row inComponent:component animated:YES];

Related

Using single UIView I want to manage tap action based on location and update specific object

enter image description here
I am making app like sudoku (9*9 boxes) but it has only binary choices (on/off) and using button gave me horrible results. Can anyone give me demo version of 9*9 (or 3*3) box where depending upon the tap location, that specific box gets toggled (on/off)
You could create a custom subclass of UIView that had an attached tap gesture recognizer and interpreted the tap location to figure out which cell is being tapped, but it would be a lot of work.
It would be better to have custom view that contains a grid of buttons and set up the button actions to do what you want.
You said "...using button gave me horrible results." Can you elaborate? That should be a good way to go, so any "horrible results" are likely the result of something you did wrong, rather than that being the wrong way to go.

UIPickerView returning previous selection as animation isn't complete

This seems to be a common occurrence, but I am unable to work out how to resolve it. I have a 'Enter' button to utilise a selected row from a picker view; however, if the animation is not yet finished the previous value is used (event though it looks like it should be picking the closest value).
My solution is to disable the 'Enter' button while the animations are taking place.
However, it would seem that the animationKeys no longer works and I am unable to work out the starting and stopping animation delegate methods of the picker view as they are called as class methods and, for the life of me, I cannot fathom how that can link to a particular view.
Can anyone shed any light on how I can determine if the picker view is being animated or how the class methods are implemented to relate to a particular object?

How to automatically load subviews for testing?

I'm writing an iOS app that has a problem on a view that's about 4 taps deep into the UINavigation stack. It's becoming a pain to have to repeatedly tap tap tap through the simulator to drill down to the UIViewController I need every time I want to run the thing.
Is there a way to automate this?
I tried just instantly calling [self tableView:self.tableView didSelectIndex... manually, however that blows up because data hasn't been loaded into the table yet...
I'd prefer something fast w/o a lot of overhead to it - otherwise it'll take more time to implement the solution than I'd save by not tapping the screen 4 times...
Thanks for any insight you guys can provide.
I do this all the time - in the appDelegate, I just add some code wrapped in a #ifdef that just makes the subview the initial view of the navigation controller. Once you get the subview working you can turn the ifdef off. Using the technique will save you lots of time - in fact I'm using it right now to add functionality to my app in the store.

Make green color UIActionSheet button?

I know I can access a individual button on a actionSheet using a for loop to access the particular button in the action sheet I want, but the thing is, how would I make a green button?
I know each button acts almost identically to a UIButton so how should I go upon making one of my buttons in the action sheet green?
I just need some tips or help with this as it is the last part of my app that isn't done!
Thanks!
When I have needed customizations for UIActionSheets, sometimes I find methods to make it happen simply, but more often I end up having to set up a custom view on way or another. I've added all manners of custom controls with:
[sheet addSubview: myCustomActionSheetController.view];
You might need to set the size as well.

How to increment a selected table row on iPhone

If someone was able to help me with the following, that would be great!
So here is what I'm trying to do. My app is basically a rss reader. The topics of the rss entries are displayed in a table view. Tapping on an entry opens a web view which displays the whole story. To this web view I have added a toolbar with up and down arrows so the user would be able to jump to the next/previous story without leaving the web view and having to tap another entry in the table. My problem is that I have no idea how to archieve this. Maybe this is related to the structure of my app. My guess is that I have to somehow increment the selected row on tapping the button.
As I said, maybe the code is a bit complicated, so I've posted the whole project here: http://www.schimanke.com/flo.zip It would be great if someone could have a look and tell me what to do.
What you need is to know which row is currently selected on your model. Since you have a reference to the model from your webview, that's easy:
int row = [mainModel.blogEntries indexOfObject:mainModel.selectedBlogEntry];
So all you need after that is to show the next (or previous) entry. Based on your code, it goes like this:
- (void) showNextPrevEntry:(int)increment usingTheOldController:(BlogEntryController *)controller {
int row = [mainModel.blogEntries indexOfObject:mainModel.selectedBlogEntry];
if (row+increment<[mainModel.blogEntries count] && row+increment>=0) {
mainModel.selectedBlogEntry = [ mainModel.blogEntries objectAtIndex:row+increment];
controller.mainModel = mainModel;
[controller viewDidLoad];
}
}
I don't think it's healthy to call viewDidLoad. Maybe you need another method just for updating the current loaded view and call that from your viewDidLoad. Also I'm not sure why you are using notifications for handling the button presses from the toolbar, but it works. :)

Resources