If anyone has used the iPhone's SMS app, there is a special animation with the compose view.
如果有人使用过iPhone的短信应用程序,则会有一个包含撰写视图的特殊动画。
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:
当您第一次按下撰写时,会显示模态视图controlelr。但是,只要您按下发送,它就会切换到您的聊天视图控制器。但这里有一些奇怪的行为:
1) The keybaord stays intact. Usually when you pop and push new controllers, you lose your keyboard positions.
1)keybaord保持不变。通常当您弹出并按下新控制器时,您将丢失键盘位置。
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.
2)进一步证明没有新控制器的弹出/推送,因为实际视图没有改变。只要按下发送,消息就会“滑动”到气泡视图。
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.
3)但是,如果确实没有弹出/推动控制器,你如何更改导航栏上的按钮?左上角的按钮也从方形“取消”按钮变为箭头状的后退按钮。
Any ideas how to implement this experience?
任何想法如何实现这种体验?
2 个解决方案
#1
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:
您可以在视图控制器中更改导航栏的特征。您还可以通过直接更改viewController.view来更改屏幕的外观。在此示例中,当用户按下发送时,您可以使用以下代码来更改导航栏:
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:
然后你实现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.
然后,在您点击发送后,他们根本无法调用[self.textField resignFirstResponder],因此键盘会保持在那里。您会注意到,如果您加载旧对话,则视图会加载屏幕底部的发送框而不是键盘。这符合UITextField对象的标准行为。
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.
直接破解视图在UIView的帮助文件中进行了解释,可能会很麻烦。老实说,我不确定他们如何绘制那个漂亮的IM界面,我会把它留给另一位专家。
#2
I've actually implemented a very similar UI for one of my apps. This is how did it:
我实际上为我的一个应用程序实现了一个非常相似的UI。这是怎么回事:
The main control is a UITableView. The two buttons at the top "call" and "add to contacts" are the table view header view.
主要控件是UITableView。顶部“呼叫”和“添加到联系人”的两个按钮是表视图标题视图。
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.
每个单元格来自8个不同的图像。 - 每个角落一个。 - 伸展并填充左上角和右上角之间的间隙。 - 伸展并填充左上角和左下角之间的间隙的一个。 - 伸展并填充右上角和右下角之间间隙的一个。 - 伸展并填充中间左侧和中间右侧之间的间隙。 - 伸展并填充左下角和右下角之间的间隙。
#1
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:
您可以在视图控制器中更改导航栏的特征。您还可以通过直接更改viewController.view来更改屏幕的外观。在此示例中,当用户按下发送时,您可以使用以下代码来更改导航栏:
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:
然后你实现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.
然后,在您点击发送后,他们根本无法调用[self.textField resignFirstResponder],因此键盘会保持在那里。您会注意到,如果您加载旧对话,则视图会加载屏幕底部的发送框而不是键盘。这符合UITextField对象的标准行为。
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.
直接破解视图在UIView的帮助文件中进行了解释,可能会很麻烦。老实说,我不确定他们如何绘制那个漂亮的IM界面,我会把它留给另一位专家。
#2
I've actually implemented a very similar UI for one of my apps. This is how did it:
我实际上为我的一个应用程序实现了一个非常相似的UI。这是怎么回事:
The main control is a UITableView. The two buttons at the top "call" and "add to contacts" are the table view header view.
主要控件是UITableView。顶部“呼叫”和“添加到联系人”的两个按钮是表视图标题视图。
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.
每个单元格来自8个不同的图像。 - 每个角落一个。 - 伸展并填充左上角和右上角之间的间隙。 - 伸展并填充左上角和左下角之间的间隙的一个。 - 伸展并填充右上角和右下角之间间隙的一个。 - 伸展并填充中间左侧和中间右侧之间的间隙。 - 伸展并填充左下角和右下角之间的间隙。