Animation for dragging a UIButton in between two other UIButton in a Collection View - objective-c

I am trying to make an app where I have a UICollectionView of UIButtons, and I want to take another UIButton from the bottom of my screen, drag it in between any other two buttons, and have them separate to make room for the new button in case the user wants to drop it in there. So far, I have been able to make my button dragable using UIPanGestureRecognizer, but haven't gone much further than that. Any suggestions or help would really be appreciated.

Related

XCode: Best Way To Handle A New View In A Tabbed Application

In an iOS Tabbed Application I'm making, I've got tabs to load different viewControllers, which is pretty standard. What I'd like to do is make a few buttons (with images on them) load up another view with the button image maximized to the screen. However, I'm not really sure how to go about doing this. I don't want a new tab for this, I just want another view to show the full image, and then a button to return to the tabbed view. I've experimented a bit with making a subview to do this, and I've attempted to change the main viewport to the new view, with no success. If someone could point me in the right direction, and maybe give me a solid concept as a jumping-off point, I would really appreciate it.
And to clarify, I'm not looking for "the best way", per se. I'd be willing to accept a quick and dirty fix. But if you know of more than one way to handle this situation, I would appreciate whichever one you personally think is better.
I would do it by creating a UINavigationController to use as the primary tab view. When you want to show the full screen button, you create a new UIViewController subclass (below) and push it. That class will return YES for the method "hidesBottomBar" (its something like that).
This new view controller will be a traditional controller. You can create a UIImageView to fill the view (or you can probably replace the view with the imageView). In the viewDidLoad you'll set the UIImage of the view (or you can enter its name in the nib).
When someone clicks on the button, then you'll pop that view and return to your tabbed view (where the tab bar is showing).
I did something like this (not a big button), so I know the tab bar can be made to hide on the push. You can also hide the navigation bar so it never is even show (again, not 100% sure at the moment how to do it but its possible).

Do I have to use buttons?

I am making an app. It is kind of a hide and go seek. I was thinking about sectioning off separate areas and having the app say something different as to where you touched the screen. It will give you clues to where on the screen you need to touch next. So, these are my questions:
What is the easiest way? Would I want to make a grid of roundrectbuttons-placing each one and making an outlet for each - or can I make grid of buttons some other on the screen.If I place each button I will have a 9x12 of buttons making 108 buttons. Then I need to have a way to choose a random button as to where the location of the thing is question is. Would I use buttons at all or is there an easier way?
108 buttons is far too many to place in a xib :) If you wanted to use buttons then I would create them programatically in viewDidLoad in your controller.
Hoewever, I wouldn't use buttons at all!
I would use a TapGestureRecognizer attached to your background view. When you recieve a tap, take a look at where it was (use locationInView:self.view) and use that to work out what to do with the press.

Objective c animating UIbutton like dock effect on mac os x

I am working on app where I have some list of content shown with some buttons . I need a dock kind of animation when I touches the button , then clicking on the docked button event should be fired. when I touches another button this one should be docked . I have seen the following like
http://praastitutki2012.wordpress.com/2009/11/23/mac-osx-dock-like-animation-for-iphone/
but , here I need to create a separate view for handling this . But I need this only for some of the buttons only , not for the entire view.
Any suggestions ?
Thanks in advance.
I didn't check in details the code you linked, but actually a UIButton is a UIView. You may consider subclassing UIButton and implement those methods. This way, animating the whole view means animating the button.

Laggy UIScrollView

At the moment I'm working on an iPad explore game which has a hexagon tile map.
I've created a UIScrollView that contains a background view (the game map) and buttons in the form of hexagons (for interaction). I add every UIButton to the view via addSubview.
But... when I add more than 100 buttons the view gets laggy (no surprise here). But what should I do to solve this?
Example:
scroll view http://img233.imageshack.us/img233/5527/screenshot2011090110353.png
Adding UIButtons isn't the way to go here. You should probably draw the "buttons" in a custom -drawRect: method and use -touchesEnded:withEvent: to decide what the user wanted to do.

adding an invisible button to the background in IB

I'm working with Xcode doing a Ipad app.
i simply want user to click anywhere on screen (not counting text fields) to perform some IBAction.I'm using an invisible button that covers my whole view.
Since I have some text fields in my view,i need to add this invisible button to the background of my user interface. I cant seem to find this option in the button attributes? any help?
Just set the button's type to custom.
Did you try setting the opacity of the button to zero?
I guess i got your point. You just want to put the UIButton(invisible) on the back of all the UITextField. The simple solution to this is open the Document Window in the IB. Now expand the view tree in the list view. Just drag your UIButton above the UITextFields and set the alpha value for the button in the property to be zero.
Hope this helps!!
iPad users don't "click". They "tap" or "touch".
In Interface Builder, I believe views are constructed with a z-index from top to bottom as they appear in the document window, so dragging your button so that it appears as the first subview of your main view should be a quick fix for this.
Have you considered other approaches? This doesn't sound like standard behaviour for an app and will probably cause havoc with anybody using Voice Over. What are you trying to accomplish?