我有以下代码
@implementation UIDevice(machine)
- (NSString *)machine
{
size_t size;
// Set 'oldp' parameter to NULL to get the size of the data
// returned so we can allocate appropriate amount of space
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
// Allocate the space to store name
char *name = malloc(size);
// Get the platform name
sysctlbyname("hw.machine", name, &size, NULL, 0);
// Place name into a string
NSString *machine = [NSString stringWithCString:name];
// Done with this
free(name);
return machine;
}
@end
/* ... …Run Code Online (Sandbox Code Playgroud) 我正在使用UIImagePickerController类从iPhone相机拍照.
我正在使用此委托方法来获取图像.
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
Run Code Online (Sandbox Code Playgroud)
但是当我在ImageView中使用该图像或将图像数据发送到某个URL时,图像会旋转90度.
有什么问题?我做得对吗?
谢谢
我在创建NSIndexPath时收到警告,
NSInteger arr[] = {0,3};
[NSIndexPath indexPathWithIndexes:arr length:2]
Run Code Online (Sandbox Code Playgroud)
warning: pointer targets in passing argument 1 of 'indexPathWithIndexes:length:' differ in signedness
是什么警告?如何使它工作?
谢谢
是否可以在Objective-C中进行系统调用?
我有以下代码:
if (!system("ls -l")) {
NSLog(@"Successfully executed");
} else {
NSLog(@"Error while executing the command");
}
Run Code Online (Sandbox Code Playgroud)
如何获得输出?
谢谢
我对这段代码感到恼火.我正在尝试在录制音频的同时获得averagePowerForChannel和peakPowerForChannel,但每次我将其设为0.0
以下是我录制音频的代码:
NSMutableDictionary *recordSetting =[[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithFloat: 22050.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:32],AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
nil];
recorder1 = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:audioFilePath] settings:recordSetting error:&err];
recorder1.meteringEnabled = YES;
recorder1.delegate=self;
[recorder1 prepareToRecord];
[recorder1 record];
levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.3f target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];
- (void)levelTimerCallback:(NSTimer *)timer {
[recorder1 updateMeters];
NSLog(@"Peak Power : %f , %f", [recorder1 peakPowerForChannel:0], [recorder1 peakPowerForChannel:1]);
NSLog(@"Average Power : %f , %f", …Run Code Online (Sandbox Code Playgroud) 加载页面时会显示谷歌地图.但是当切换离子段时,不会显示地图.以下是我的离子2代码:
<ion-header>
<ion-toolbar no-border-top>
<ion-segment [(ngModel)]="social" (ionChange)="segementChangeAction()">
<ion-segment-button value="activity">
Map
</ion-segment-button>
<ion-segment-button value="messages">
Messages
</ion-segment-button>
</ion-segment>
</ion-toolbar>
</ion-header>
<ion-content no-bounce>
<div [ngSwitch]="social">
<div *ngSwitchCase="'activity'">
<div #map id="map"></div>
</div>
<div *ngSwitchCase="'messages'">
Some text.....
</div>
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud) 是否可以在目标C中创建.zip文件?
有可用的图书馆或建议吗?
objective-c ×5
iphone ×3
unix ×2
avfoundation ×1
command ×1
google-maps ×1
ionic2 ×1
nsindexpath ×1
settings ×1
system-calls ×1
uiimage ×1
xcode ×1
zip ×1