Manipulate the iPhones UIKeyboard as a "regular" UIView - iphone

Im struggling a bit with the UIkeyboard, I have a datePicker, IntervalPicker some custom pickers and a few other UI elements that live in the same part of the screen as the keyboard.
I have build a factory class that places these on the screen depending on the state of the app, I control animation and layering myself and here the problem starts. It all works for the elements I mentioned, but the Keyboard I can't seem to control to the same extend.
I would like to instantiate a keyboardView, place it on the screen with an alpha of 0 inside an UIView and when Im good and ready, fade and animate it in.
It seems I can only get a Keyboard on the screen if I build a textField and then set it as firstResponder, this results in the keyboard animating in as expected, but it completely breaks my factory approach.
Hope it makes sense:) thanks for any help given.

The keyboard isn't a regular view. You have to stop trying to use it like one.
How to pull up a UIKeyboard without a UITextField or UITextView?
Don't fight with the SDK, make the sdk your friend.

Related

Rolodex-like iOS App that Vertically Scrolls

I want to create an app that looks like a Rolodex Card wherein you'll have to scroll vertically in different views and when tapped, will go on full screen view with a close button to return to the previous view in a Rolodex-kind-of-menu. I want it to look similar to the PepperUI iOS control but instead of having it horizontally scroll, I want it scrolled vertically like in the picture below:
Any idea on how I can implement this kind of app? I'm thinking that this will only have Core Animations involved when scrolling the cards-like view controllers and zooming on a specific view when the user tapped any view in the cards.
Thanks for any input on this.
i would suggest this iCarousel by NickLockwood. Great Project. You can tweak it the way you want it, believe me. Make it vertical, and look up into its type cause it supports 11 types including like the one you want. Check it out!
Hope this helps.

Show a UINavigationBar back button without pushing a view controller

In the iPad's Photos app, when you tap an album the stack of pictures expands to fill the screen - you're in the same view, it's just rearranged the grid a little. But at the top, a left-arrow-style Back button appears, as if pushViewController had been used - except it fades in neatly, rather than sliding in. When you tap that, it fades out again, rather than sliding out.
Is there a way to replicate this behaviour? I've tried a few options so far, and might just be missing something. What I've tried:
Setting self.navigationItem's leftBarButtonItem works, but gives me a square button rather than an angled Back-style one - there are a few hacks online to make this work, such as using pictures for the button, but I'd rather only use them if there's definitely no "official" way to do this.
Setting self.navigationItem.backBarButtonItem - this is generally used to customise the back button when a view controller is pushed, so it has no effect.
[self.navigationController.navigationBar setItems::] - this works, although it gives me the sliding animation rather than fading. As a result, I use animated:NO to make it just appear. Downside: when tapping Back, you do get the sliding out animation, which looks weird because the rest of the UI stays still.
Has anyone managed to replicate this effect?
Thanks in advance!
Your first approach is probably the best.
It doesn't have to be super-hacky, you can use a normal UIButton and customize it to look like a back-button using backgroundImageForState: and titleForState: (etc.), then set the UIButton object as the customView of your UIBarButtonItem.
Many apps these days customize the look & feel of the buttons anyway, so using a custom background image is quite normal. If you use resizableImageWithCapInsets: (or stretchableImageWithLeftCapWidth:topCapHeight: if you need to support iOS earlier than 5.0) then the button can still stretch to fit whatever text goes inside, and as it's a normal UIButton the text is localizable, etc. I don't consider this approach to be hacky, it is a perfectly sensible way to get around the limited functionality of UIBarButtonItem objects.
Better late than never.
To show a back button without pushing a view controller, use pushNavigationItem:animated: and popNavigationItemAnimated: on UINavigationBar. These result in the standard slide animation and creation of a back button. However, there is no way to ensure your content animation runs for the same time as the bar animation other than making an educated guess at the duration.
Since iOS 7 there is a better API for achieving this effect, where you still push and pop view controllers but you provide a custom transition animation through navigationController:animationControllerForOperation:fromViewController:toViewController: from UINavigationControllerDelegate. This allows the animations between the bar and content to be perfectly coordinated.
Finally, if your content before and after is managed by UICollectionViewController, you can use useLayoutToLayoutNavigationTransitions, which is designed for use-cases like Photos.

Springboard-like scrolling/view switching with snapping on iOS

Is there a way in cocoa touch to implement view switching behavior like the one in iPhone's springboard? I mean horizontal scrolling with 'snap to view' animation (views are switched only after certain 'scrolling' threshold has been reached)
Look at the 'pagingEnabled' property on UIScrollView.
SpringBoard, App Store and Mobile Safari use a UIPageControl in conjunction with a UIScrollView to provide the little dots you see at the bottom of the screens, that you swipe across with that snap effect.
What views you want to swipe through depends on your application, though, as you're essentially swiping through a UIScrollView.
This isn't an answer, but I know it's possible. I have seen this behavior in "Twitter for iPhone" and asked myself the same question. If you use that app, check out what happens when you swipe the individual tweets to reveal more controls underneath.
This looks like it's part of TableCellView and some touch drag combination. As for the implementation of that... well, im too novice right now.

Drag & sweep with Cocoa on iPhone

I'm about to start a new iPhone app that requires a certain functionality but I'm not sure if it's doable. I'm willing to research but first I just wanted to know if I should at least consider it or not.
I haven't seen this in an app before (which is my main concern, even though I haven't seen too many apps since I don't own an iPhone), but an example would be the iPhone shortcuts panels: you can hold on an app, and then drag it to another panel, sweeping while still dragging it. But this is the core app, is it possible to reproduce something similar within a normal app?
I only need to be sure it can be done before I start digging, I don't need code examples or anything, but if you have some exact resources that you consider helpful, that would be appreciated.
Thanks!
Yes. If you have your custom UIView subclass instance inside a UIScrollView, your view controller just needs to set the UIScrollView to delay content touches and not allow it to cancel touch events.
[scrollView setCanCancelContentTouches:NO];
[scrollView setDelaysContentTouches:YES];
When the user taps and holds in the custom view, the event goes to that custom view, which can process the touch events to drag an item around, but if the user quickly swipes, it scrolls the view.
The "panel" view that you're referring to appears to be a UIPageControl view — although, perhaps, the specific incarnation of this view that Apple uses for the iPhone's home page may be customized.
Instances of generic UIView views that you might touch-and-drag will receive touch events. By overriding methods in the view, these events can be processed and passed to the page control, in order to tell it to "sweep" between pages.
If I wanted to do what you're asking about, that's how I might approach it. It seems doable to me, in any case.
Start with this: Swip from one view to the next view
Try using a UIButton that tracks the time since the state of the button changed to "highlighted". You may need to do this in order to track the dragging and move the button around:
Observing pinch multi-touch gestures in a UITableView
Check to see if the button starts overlapping one side of the screen while being dragged. If s certain amount of time elapses since the button first started overlapping the edge and then manipulate the UIScrollView so that it switches to the next page on the corresponding side of the screen
You may need to use NSTimer to keep track of how long the button is held down, etc.
In any case there's no reason why this couldn't work.
If UIButton doesn't work then perhaps try a custom subclass of UIControl (which tracks the same touch down actions etc.). If that doesn't work then use the window event intercept thing to track everything.

How to create a full-screen modal status display on iPhone?

I'm trying to create a modal status indicator display for an iPhone app, and would like one similar to this one used in Tweetie:
Specifically, this one "shades out" the entire screen, including the toolbar. I don't believe through any normal UIView manipulation, I can extend past the bounds of my window, can I? I believe I've seen a status indicator like this somewhere else on iPhone, possibly when I added an Exchange e-mail account.
I've tried subclassing UIAlertView and overriding its drawRect method. If I don't call [super drawRect:] it doesn't ever display the normal UIAlertView text box, however my drawing rectangle is in an odd size and position.
Anyone have any advice to accomplish this?
Check out MBProgressHUD.
Take a look at the source code to the WordPress application. They have code which you can basically drag and drop into your application to do this.
http://iphone.wordpress.org/development/
I haven't done this myself, but you could layer a UIView at the top of the view hierarchy, and use setHidden to dynamically show or hide it. Since it's at the top of the stack, it should be able to intercept all touch events.