If anyone has used the iPhone's SMS app, there is a special animation with the compose view.
When you first press compose, a modal view controlelr is shown. However as soon as you press send, it shifts to your chat view controler. But here are a few weird behavior:
1) The keybaord stays intact. Usually when you pop and push new controllers, you lose your keyboard positions.
2) Further evidence that there was no pop/pushing of new controllers because the actual view did not change. As soon as you press send, the message "slides" up to the bubble view.
3) However, if there really IS no popping/pushing of controllers, how do you change the buttons on the navigationbar? The top left button also changed from the square "cancel" button to a arrow-like back button.
Any ideas how to implement this experience?
You can change the characteristics of the navigation bar in a view controller. You can also change the appearance of the screen by altering the viewController.view directly. In this example, when the user presses send you could use the following code to alter the nav bar:
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:#"Messages:(%i)", messageCount] style:UIBarButtonStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = back;
[back release];
UIBarButtonItem *edit = [[UIBarButtonItem alloc] initWithTitle:#"Edit" style:plain target:self action:#selector(editMessage)];
self.navigationItem.rightBarButtonItem = edit;
[edit release]
And then you implement editMessage:
- (void)editMessage {
//Go into edit mode, whatever that code looks like.
}
They then simply fail to call [self.textField resignFirstResponder] after you hit send, so the keyboard stays up there. You will notice that if you load an old conversation the view loads with the send box on the bottom of the screen and no keyboard. This is in keeping with the standard behavior of UITextField objects.
Hacking the view directly is explained in the help files for UIView, and can be kind of a pain. I'm honestly not sure how they draw that pretty IM interface, I'll leave that up to another expert.
I've actually implemented a very similar UI for one of my apps. This is how did it:
The main control is a UITableView. The two buttons at the top "call" and "add to contacts" are the table view header view.
Each cell is drawn from 8 different images.
- One for each corner.
- one that stretch and fills the gap between the top left and top right corners.
- One that stretch and fills the gap between the top left and bottom left corners.
- One that stretch and fills the gap between the top right and bottom rightt corners.
- One that stretch and fills the gap between the middle left and the middle right.
- One that stretch and fills the gap between the bottom left and bottom right corners.
Related
The question is in the title.
There must be a simpel way to do this I guess?
There is an imageview on the screen, there doesn't have to be any interaction with it.
On the imageview I want 2 small buttons left and right but the buttons were created (and the code is written) before the imageview. How do I set this imageview to the background? :)
[self.view sendSubviewToBack:yourImageView];
You can add buttons as subview of imageview.
you can write below code for that:
[imageView addSubview:button1];
[imageView addSubview:button2];
So buttons will be appear in foreground.
When looking at your xib or stoyboard (where you can see the layout), you can use the View Controller scene which is a list of all of the objects, views etc on your Apps layout.
You can click and drag the UI image view so its above the buttons in the list. I'm guessing it's just defaulted to being on top of the buttons.
In your storyboard, choose your viewController by clicking on it. On left side you can see hierarchy like left side view in this image. Check if your imageView is below, in hierarchy, to your 2 buttons. If it is, then drag the imageView and move it above both the buttons.
Concept : The view that is below in hierarchy is visible on top of all the views above it.
I am able to customize the back button on my navigation bar, but in order for me to show the left arrow shape, do I need to create my customized image with the left arrow specifically?
Or there is a way to use the original back button with the arrow shape, while just apply my background image onto it?
Thanks in advance!
Set yourButton the customized image with the left arrow
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:yourButton] autorelease];
You cannot modify the original BACK button.
I have a UIWebView that is sandwiched in between a UINavigationController (top) and a UIToolbar (bottom). When the user taps twice on the UIWebView, I want to smoothly animate the top and bottom bars to hide. However, when I use this code (and several other different variations of this concept), the bar hides fine, but sometimes (sometimes not) the UIWebView content scrolls up 20-30px:
[self.navigationController setNavigationBarHidden:YES animated:YES];
It works sometimes, and then other times it doesn't. I just want to be able to smoothly hide/unhide both bars, changing the UIWebView size to full screen/not full screen as I go.
Anybody done this? Or know what is going on here?
make your UINavigationBar translucant
self.navigationController.navigationBar.translucent = YES;
in your viewWillAppear method.
I have a toolbar, where I want to have one UIBarButtonItem centered and have another on the very right. However when I add the button on the right, my centered button gets shifted further to the left (see attached). I can't figure out how to get this resolved without using code (I would like to use interface builder only). Any ideas?
To do this in just IB, add a fixed bar button item to the very left of the bar that's the exact same width of the 'switch camera' button, followed by a flexible button, your camera icon, another flexible space, and the switch camera.
So it would look like:
|--fixed space--||--flexible space--||Camera Button||--flexible space--||switch camera|
How to show a small pop up on click of button on a view that will be displayed in small region of the parent view.
You can simply define the frame for your view, and add it as a subview of its parent.
newView.frame = CGRectMake(60, 140, 200, 200);
[parentView addSubview:newView];
Just putting up a view is pretty straightforward (create a UIView, position it, then addSubview it to the parent). But there are a few UI design questions you may want to ask yourself before you pop something up. Things like:
Is the pop-up modal? Once it's up can the user do something else or do they have to 'dismiss' the view before continuing.
How does the user dismiss the view? Do they tap the view itself, some sort of 'close' object, or tap outside of it?
Where do you position the pop-up view if you're too close to the side of the window (otherwise it gets clipped and the user can't see all of it).
Should you offset it from the button itself so the tapping finger isn't covering up the item? How many pixels work best? And does the offsetting bring the view too close to the edge, so maybe show it on the other side so it's not clipped?
And they say UI design is easy ;-)