Возможно, вы могли бы попробовать ClientMessageInspector, его AfterReceiveReply будет вызываться каждый раз, когда клиент получает сообщение.
public class MyClientMessageInspector : IClientMessageInspector
{
Your message box
public void AfterReceiveReply(ref Message reply, object correlationState)
{
show message in your message box
}
public MyClientMessageInspector ( ){
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
return null;
}
}
Чтобы зарегистрировать инспектора, вам нужно использовать endpointBehavior
public class MyEndpointBehavior : IEndpointBehavior
{
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.ClientMessageInspectors.Add( new MyClientMessageInspector();
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
, а затем добавить поведение к вашему клиенту.
using (ChannelFactory<IService> ChannelFactory = new ChannelFactory<IService>("myservice"))
{
ChannelFactory.Endpoint.EndpointBehaviors.Add(new MyEndpointBehavior());
IService service = ChannelFactory.CreateChannel();
// call method
}
Вы захотите зарегистрировать свой viewController для UIKeyboardDidShowNotification
и UIKeyboardWillHideNotification
события. Когда Вы получаете их, необходимо скорректировать границы таблицы; клавиатура 170 пикселей высотой, поэтому просто уменьшите или вырастите свои границы таблицы соответственно, и она должна правильно корректироваться на клавиатуру.
Просто удостоверьтесь, что у Вас есть достаточно пространства прокрутки ниже этого. Поскольку согласно моему знанию iPhone автоматически корректирует и показывает сфокусированное текстовое поле в то время, когда его клавиатура появляется.
Удаление/комментарий строк, где реагирование высоко изменяется, кажется, решает проблему.Спасибо.
Измененный код:
# define kOFFSET_FOR_KEYBOARD 150.0 // keyboard is 150 pixels height
// Animate the entire view up or down, to prevent the keyboard from covering the author field.
- (void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
// Make changes to the view's frame inside the animation block. They will be animated instead
// of taking place immediately.
CGRect rect = self.view.frame;
CGRect textViewRect = self.textViewBeingEdited.frame;
CGRect headerViewRect = self.headerView.frame;
if (movedUp) {
// If moving up, not only decrease the origin but increase the height so the view
// covers the entire screen behind the keyboard.
rect.origin.y -= kOFFSET_FOR_KEYBOARD;
// rect.size.height += kOFFSET_FOR_KEYBOARD;
} else {
// If moving down, not only increase the origin but decrease the height.
rect.origin.y += kOFFSET_FOR_KEYBOARD;
// rect.size.height -= kOFFSET_FOR_KEYBOARD;
}
self.view.frame = rect;
[UIView commitAnimations];
}
Проверьте этот вопрос: список UITableView доступных для редактирования текстовых полей
Эта проблема может быть сложной в зависимости от вашего сценария пользовательского интерфейса. Здесь я рассмотрю сценарий, в котором UITextField или UITextview находится в UITableViewCell.
Вам необходимо использовать NSNotificationCenter для обнаружения события UIKeyboardDidShowNotification. см. http://iosdevelopertips.com/user-interface/adjust-textfield-hidden-by-keyboard.html.Вам нужно уменьшить размер кадра UITableView, чтобы он занимал только ту область экрана, которая не закрыта клавиатурой.
Вам нужно вызвать
[myTableView selectRowAtIndexPath:self.indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];`
, чтобы программно «нажать» на ячейку.
Если вы реализуете обе точки, вы увидите положение UITextView/Field прямо над клавиатурой. Имейте в виду, что UITableViewCell, в котором находится UITableView/Field, не может быть выше, чем «не покрытая» область. Если это не так для вас, для этого есть другой подход, но я не буду обсуждать это здесь.