小编Jyo*_*sna的帖子

如何将字节数组转换为字符串,反之亦然?

我必须在Android中将字节数组转换为字符串,但我的字节数组包含负值.

如果我再次将该字符串转换为字节数组,我得到的值与原始字节数组值不同.

我该怎么做才能获得正确的转换?我用来进行转换的代码如下:

// Code to convert byte arr to str:
byte[] by_original = {0,1,-2,3,-4,-5,6};
String str1 = new String(by_original);
System.out.println("str1 >> "+str1);

// Code to convert str to byte arr:
byte[] by_new = str1.getBytes();
for(int i=0;i<by_new.length;i++) 
System.out.println("by1["+i+"] >> "+str1);
Run Code Online (Sandbox Code Playgroud)

我陷入了这个问题.

java

228
推荐指数
11
解决办法
55万
查看次数

如何检测iphone处于静音模式

我正在开发一个应用程序.因为我想通过编码检测"iPhone是否处于静音模式?".我正在使用Objective-C的可可开发它.

如果有人知道它善意回复.

iphone audio cocoa-touch objective-c ios

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

如何在plist中写入数据?

我在资源文件夹中创建了save.plist.我直接在其中写了一些数据(不使用编码).我能够读取该数据,但我无法通过代码写入同一个save.plist.通过使用以下代码,我试图写入数据,但它存储在我的.app plist中.代码在这里

NSString *errorDesc = nil;

NSPropertyListFormat format;

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"save" ofType:@"plist"];

NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];

NSMutableDictionary *temp = (NSMutableDictionary *)[NSPropertyListSerialization
                     propertyListFromData:plistXML
                              mutabilityOption:NSPropertyListMutableContainersAndLeaves
                  format:&format errorDescription:&errorDesc];

if (!temp) {

    NSLog(errorDesc);

    [errorDesc release];        
    }
    //  [temp setValue:@"123" forKey:@"line1"];
    //  [temp writeToFile:plistPath atomically: YES];

    //Reading data from save.plist
    NSLog([temp objectForKey:@"name"]);
    NSLog([temp objectForKey:@"wish"]);
    NSNumber *num=[temp valueForKey:@"roll"];
    int i=[num intValue];
    printf("%d",i);
        //writitng the data in save.plist

    [temp setValue:@"green" forKey:@"color"];
    [temp writeToFile:plistPath atomically: NO];
    NSMutableDictionary *temp1 = (NSMutableDictionary *)[NSPropertyListSerialization
                propertyListFromData:plistXML                                                            
                                mutabilityOption:NSPropertyListMutableContainersAndLeaves …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa objective-c

16
推荐指数
2
解决办法
6万
查看次数

如何在横向模式下转换导航栏和导航控制器

我正在开发一个游戏,我正在使用横​​向模式,我有4个视图.2个视图正在以横向模式进入.但在第三个视图中我有UITable和导航栏.我可以在横向模式下旋转表,但无法转换导航栏和导航控制器.导航栏和导航控制器上也有Button.它也没有变形.所以任何人都可以解决这个问题.:)

iphone cocoa-touch objective-c

5
推荐指数
2
解决办法
3903
查看次数

在Landscape模式下使用Interface Builder进行编程

我想在Landscape模式下使用Interface Builder设计应用程序.我不知道如何将控件放在横向模式下.我只知道通过使用self.transform来旋转我的UIView.我是新手.所以任何人都可以帮助我.

iphone xcode cocoa-touch interface-builder

3
推荐指数
2
解决办法
6679
查看次数

标签 统计

iphone ×4

cocoa-touch ×3

objective-c ×3

audio ×1

cocoa ×1

interface-builder ×1

ios ×1

java ×1

xcode ×1