小编Tak*_*aga的帖子

iPad分体键盘

我正在创建一个类似于iPad的iMessage应用程序的应用程序,它可以进行消息传递.因此,当显示键盘时,有一个输入视图锚定在消息视图的底部并输入附件视图.在停靠或取消停靠时显示键盘时,必须正确调整消息视图的大小.

我遇到的问题是来自UIKeyboardWillChangeFrameNotification的通知数据不一致.

首先,用户可以通过3种方式取消键盘:

  1. 按住右下方的键,然后向上滑动
  2. 按住右下方的键,弹出菜单时选择"取消停靠"
  3. 按住右下方的键,弹出菜单时选择"拆分"

对于案例#1,来自UIKeyboardWillChangeFrameNotification的通知数据是一致的.这是数据:

userInfo = {
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}
Run Code Online (Sandbox Code Playgroud)

对于情况#2和#3,数据不一致,这是我收到的:

userInfo = {
    UIKeyboardAnimationCurveUserInfoKey = 0;
    UIKeyboardAnimationDurationUserInfoKey = "0.25";
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {384, 872}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {384, 1136}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
    UIKeyboardFrameChangedByUserInteraction = 0;
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, -264}, {768, 304}}";
}
Run Code Online (Sandbox Code Playgroud)

这里很奇怪的是,当我在#2或#3情况下监听UIKeyboardDidChangeFrameNotification时,数据按预期进入:

userInfo = {
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}
Run Code Online (Sandbox Code Playgroud)

为什么通知数据不同?有没有人找到一种清晰的方法来检测分裂键盘事件?

objective-c keyboard-events ipad

9
推荐指数
1
解决办法
3017
查看次数

通过Intent调用BroadcastReceiver时,它运行的是什么进程?

我知道我们有10秒的时间处理意图; 否则,看门狗计时器将启动.它假设是一个轻量级的功能.所以我的问题是,BroadcastReceiver与root活动在同一进程中运行吗?或者它是否在Zygote系统进程上运行?

android process broadcastreceiver android-intent

6
推荐指数
1
解决办法
811
查看次数

Android的自定义状态栏通知错误?

我试图通过远程视图在状态栏上显示自定义通知内容.我在宽度和高度都使用fill_parent,但右侧总是有一个小间隙.我在这做错了什么?

请看这里的屏幕截图:http://img684.imageshack.us/img684/2347/devicenq.png

布局代码(我也使用了LinearLayout):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="@color/solid_yellow"
              >
    <ImageView android:id="@+id/image"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_marginRight="10dp"
              android:src="@drawable/stat_sample"
              />
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:textColor="#000"
              android:text="Hello, this message is in a custom expanded view"
              />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是代码片段:

Intent notificationIntent = new Intent(this, MessengerService.class);
PendingIntent contentIntent = PendingIntent.getActivity(
    this, 0, notificationIntent, 0);

Notification notification = new Notification(R.drawable.stat_sample,
    "Hello", System.currentTimeMillis());

RemoteViews contentView = new RemoteViews(getPackageName(),
    R.layout.custom_notification_layout);

notification.contentView   = contentView;
notification.contentIntent = contentIntent;

mNM.notify(R.string.remote_service_started, notification);
Run Code Online (Sandbox Code Playgroud)

我整天都在用这个敲打我的头......谢谢.

notifications android statusbar

6
推荐指数
1
解决办法
1705
查看次数