小编Ale*_*lex的帖子

XCode 4目标部署目标与项目部署目标

请原谅我的无知,但是"目标"下的部署目标字段与"项目"下的部署目标之间的XCode 4有何不同?

如果我的项目部署目标是3.2,而我的iOS应用程序目标是4.0,会发生什么?或相反亦然?

iphone xcode

47
推荐指数
3
解决办法
5134
查看次数

以编程方式解除DialogFragment

如何以编程方式解雇DialogFragment?我目前通过以下方式创建对话框:

void showDialogWithId(int id){

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    if (id == SEARCHING_DIALOG){

        // Create and show the dialog.
        DialogFragment newFragment = MyDialogFragment.newInstance(SEARCHING_DIALOG,"TEST");
        newFragment.show(ft, "dialog");
    }

    if (id == CONNECTING_DIALOG){

        // Create and show the dialog.
        DialogFragment newFragment = MyDialogFragment.newInstance(CONNECTING_DIALOG,"TEST");
        newFragment.show(ft, "dialog");
    }

    if (id == CONNECTIVITY_DIALOG){


        // Create and show the dialog.
        DialogFragment newFragment = MyDialogFragment.newInstance(CONNECTIVITY_DIALOG);
        newFragment.show(ft, "dialog");
    }

}
Run Code Online (Sandbox Code Playgroud)

我希望通过以下方式解雇他们:

public void dismissDialog(){

    getFragmentManager().popBackStack();

    FragmentTransaction ft = …
Run Code Online (Sandbox Code Playgroud)

android

38
推荐指数
2
解决办法
4万
查看次数

远程通知方法调用两次

application:didReceiveRemoteNotification:fetchCompletionHandler:在我的应用程序委托中实现了响应推送通知.

当应用程序在后台时收到通知时,会立即调用此方法,并在完成后获取新数据并执行完成块.全部按照文档.但是,如果我点击通知警报,则会再次调用此方法,从而导致另一个网络调用和UI更新.我希望每个推送通知都会调用一次此方法,而不是一次收到,再次执行操作.

其他人如何实施这种方法?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [self loadSomeResource:^(NSData *data,NSError *error){
        if (error) {
            completionHandler(UIBackgroundFetchResultFailed);
        }
        else if (data){
            completionHandler(UIBackgroundFetchResultNewData);
        }
        else {
            completionHandler(UIBackgroundFetchResultNoData);
        }
    }];
}
Run Code Online (Sandbox Code Playgroud)

objective-c push-notification ios ios7

13
推荐指数
1
解决办法
6242
查看次数

在LinearLayout中使用layout_weight和ImageView

我试图在屏幕中间放置一个ImageView,目的是在其上方和下方放置其他视图,因此我决定使用LinearLayout(垂直)和LinearLayout(水平).但是,当我对ImageView使用layout_weight时,图像完全消失(显示空白屏幕).ImageView的图像在onCreate()中设置.我希望ImageView占据屏幕宽度的50%,因此我使用了权重.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">

<View
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal"
android:layout_weight="2">

<View android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>

    <ImageView android:layout_weight="2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/albumArtImageView"></ImageView>

    <View android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>

</LinearLayout>
<View
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout

4
推荐指数
1
解决办法
1万
查看次数

从主机名获取服务器IP地址

执行NSURLRequest主机名时,是否可以获取响应来自的服务器的IP地址?

NSURL方法:

- (NSString *)host;
Run Code Online (Sandbox Code Playgroud)

只返回主机名,我看不到从任何其他NSURL方法获取IP地址的方法.

也许有一种方法在启动之前执行主机查找NSURLRequest

networking cocoa-touch objective-c ios

4
推荐指数
1
解决办法
5323
查看次数

使用Map和Reduce进行分组

我有一些文件的"状态"字段为"绿色","红色","琥珀色".

我确信可以使用MapReduce来生成包含三个键(每个状态一个)的分组响应,每个键的值包含具有该键的所有文档的数组.但是,我正在努力研究如何使用re(reduce)函数.

地图功能:

function(doc) {
  emit(doc.status, doc);
}
Run Code Online (Sandbox Code Playgroud)

减少功能:???

couchdb mapreduce

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

Jackson ObjectMapper - 未映射"_"的属性

我在以下情况下使用ObjectMapper,但是,Person类的JSON属性为"last_name",当"name"属性映射正确时,它似乎没有被映射.我在下面列出了我的Person类.任何可能发生这种情况的原因都值得赞赏.杰克逊核心/映射器1.8.5正在使用.

ObjectNode node = (ObjectNode) row.getDocAsNode();

try {
        Person person = mapper.readValue(node, Person.class);

        tt.setText(person.getName());

        bt.setText(person.getLastName());

    } catch (JsonParseException e) {

        e.printStackTrace();
    } catch (JsonMappingException e) {

        e.printStackTrace();
    } catch (IOException e) {

        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

人员类:

@JsonIgnoreProperties(ignoreUnknown = true)

public class Person {

private String _name;
private String _last_name;

public String getName() { return _name; }
public String getLastName() { return _last_name; }

public void setName(String str) { _name = str; }
public void setLastName(String str) { _last_name = str; } …
Run Code Online (Sandbox Code Playgroud)

java android json jackson

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

通用协议扩展和"自我"

我有一个协议,定义从服务器获取对象数组的能力.ResultAlamofire中定义:

protocol BulkFetchable {

    static func fetch(limit : Int, skip : Int, completionHandler : ((request : NSURLRequest?, response : NSHTTPURLResponse?, result : Result<[Self]?>) -> Void)) -> Request

}
Run Code Online (Sandbox Code Playgroud)

我使用通用实现来扩展此协议(忽略端点为此问题的目的而修复的事实):

extension BulkFetchable where Self : Mappable {

    static func fetch(limit: Int, skip: Int, completionHandler: ((request: NSURLRequest?, response: NSHTTPURLResponse?, result: Result<[Self]?>) -> Void)) -> Request {
        return Alamofire.request(.GET, "http://localhost:4567/users.json", parameters: ["limit" : limit, "skip" : skip], encoding: .URL, headers: nil).responseArray(completionHandler)
    }

}
Run Code Online (Sandbox Code Playgroud)

我正在使用Alamofire的扩展Request,将JSON响应转换为可选的类型数组T,其中T …

generics swift

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

RACSignal指示属性何时返回其初始值

我有一个属性,如果a 处于状态或状态recording,则更改为.YESUILongPressGestureRecognizerUIGestureRecognizerStateBeganUIGestureRecognizerStateChanged

如何创建一个仅在recording返回时而NO不是在其初始值时触发的信号?

ios reactive-cocoa

0
推荐指数
1
解决办法
1104
查看次数