目前,我们正在定义一个扩展日志机制来打印出日志的类名和源行号.
#define NCLog(s, ...) NSLog(@"<%@:%d> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \
__LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__])
Run Code Online (Sandbox Code Playgroud)
例如,当我调用NCLog(@"Hello world")时; 输出将是:
<ApplicationDelegate:10>Hello world
Run Code Online (Sandbox Code Playgroud)
现在我还想注销方法名称,如:
<ApplicationDelegate:applicationDidFinishLaunching:10>Hello world
Run Code Online (Sandbox Code Playgroud)
因此,当我们知道调用哪种方法时,这将使我们的调试变得更容易.我知道我们也有Xcode调试器,但有时候,我也希望通过注销来进行调试.
我想以编程方式在用户的iphone上找出货币区域设置.这意味着,如果用户在美国商店,货币区域应该是美元,对于澳大利亚,它应该是澳元.我的目的是尝试将我们应用程序中列出的商品价格转换为几乎与AppStore要求的价格相匹配.
例如,如果我们销售视频3美元,而澳大利亚人想购买它,那么我应该在我的应用程序屏幕上显示2.8澳元.它将减少用户对其国家实际价格的计算.有谁知道怎么做?
我试图AVPlayer
在一个更大的视图内截取屏幕截图.我想只构建一个测试框架,所以私有APIs
或任何方法都是好的,因为在发布到AppStore时不会包含框架.
我试过用
UIGetScreenImage()
:在模拟器上运行良好但在设备上运行不正常 snapshotviewafterscreenupdates
:它显示视图,但我不能创建一个UIImage
.drawViewInHierarchy
并且renderInContext
不会合作AVPlayer
AVAssetGenerator
用于从视频中获取图像,很难获得良好的坐标或视频播放器作为其他视图的子视图我正在使用AVFoundation并从中获取样本缓冲区AVCaptureVideoDataOutput
,我可以使用以下命令将其直接写入videoWriter:
- (void)writeBufferFrame:(CMSampleBufferRef)sampleBuffer {
CMTime lastSampleTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
if(self.videoWriter.status != AVAssetWriterStatusWriting)
{
[self.videoWriter startWriting];
[self.videoWriter startSessionAtSourceTime:lastSampleTime];
}
[self.videoWriterInput appendSampleBuffer:sampleBuffer];
}
Run Code Online (Sandbox Code Playgroud)
我现在要做的是在CMSampleBufferRef中裁剪和缩放图像,而不将其转换为UIImage或CGImageRef,因为这会降低性能.
我尝试在raw/assets文件夹中读取视频文件,我尝试了以下方法,但没有一个工作.我正在测试API 16.每种方法,我尝试使用和不使用mp4扩展.我真的很感激有人可以帮助我
所有方法都不会崩溃,MediaMetadataRetriever
可以设置数据源,但不能获取宽度,高度和截图.VideoExtractor
总是回来
06-04 16:44:10.519: E/FileSource(8695): Failed to open file FILE_PATH. (No such file or directory)
06-04 16:44:10.519: E/DecodeActivity(8695): Can't find video info!
Run Code Online (Sandbox Code Playgroud)
方法1:android.resource
String filePath = "android.resource://" + this.activity.getPackageName() + "/raw/green_backhand_slice";
videoExtractor.setDataSource(activity.getApplicationContext(), Uri.parse(filePath), null);
metaRetriever.setDataSource(act.getApplication(), Uri.parse(filePath));
Run Code Online (Sandbox Code Playgroud)
方法2:android_asset
this.filePath = "file:///android_asset/green_backhand_slice";
videoExtractor.setDataSource(activity.getApplicationContext(), Uri.parse(this.filePath), null);
metaRetriever.setDataSource(act.getApplication(), Uri.parse(filePath));
Run Code Online (Sandbox Code Playgroud)
方法3:资产文件描述符
AssetFileDescriptor assetFD = null;
try {
assetFD = getAssets().openFd("green_backhand_slice.mp4");
} catch (IOException e) {
e.printStackTrace();
}
metaRetriever.setDataSource(assetFD.getFileDescriptor());
Run Code Online (Sandbox Code Playgroud) 继续上一个问题:Obj-C中的日志方法名称.我只是想知道是否有办法打印变量名称.例如:
NSString *name = "vodkhang";
NCLog(@"%@", name);
Run Code Online (Sandbox Code Playgroud)
我希望输出应该是:
name: vodkhang
Run Code Online (Sandbox Code Playgroud)
只是总结一下上一篇文章,目前我可以在打电话时打印出班级名称,方法名称和行号
NCLog(@"Hello World");
<ApplicationDelegate:applicationDidFinishLaunching:10>Hello world
Run Code Online (Sandbox Code Playgroud)
同
#define NCLog(s, ...) NSLog(@"<%@:%d> %@", __FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__])
Run Code Online (Sandbox Code Playgroud) 我正在尝试将所有联系人都放在Android联系人的收藏夹列表中.目前,我可以获取所有组ID,包括最喜欢的组ID.但似乎没有联系人将组ID作为最喜欢的组ID.
我正在尝试在每个组中获取所有组ID和联系人.打印完两个列表后,我发现收藏夹的组ID不在联系人列表中
ArrayList<String> favGroupId=new ArrayList<String>();
final String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor cursor = getContentResolver().query(
ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
null, ContactsContract.Groups.TITLE);
while (cursor.moveToNext()) {
String id = cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups._ID));
Log.v("Test",id);
String gTitle = (cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups.TITLE)));
Log.v("Test",gTitle);
if (gTitle.contains("Favorite_")) {
gTitle = "Favorites";
favGroupId.add(id);
}
}
cursor.close();
Run Code Online (Sandbox Code Playgroud) 我有两个实体,我称之为A和B.它们在两个方向都配置了To-Many关系,因此A.myBs和B.myAs都是NSSets.
这是我奇怪的问题.
当我向我的A实体添加B时,我使用mutableSetValueForKey这样做:
NSMutableSet *myBSet = [myA mutableSetValueForKey:@"myBs"];
[myBSet addObject:theBtoAdd];
Run Code Online (Sandbox Code Playgroud)
这会将theBtoAdd添加到A实体,但不会添加反向关系.核心数据上下文保存不会导致任何错误,但我的A对象没有B逆集.如果我退出应用程序,则甚至不保存部分关系.
这是奇怪的部分...如果我只是切换我的代码并执行相反的操作(有理由为我的特定应用程序更难做到这一点) - 将A添加到B而不是像这样添加B到A:
NSMutableSet *myASet = [myB mutableSetValueForKey:@"myAs"];
[myASet addObject:theAtoAdd];
Run Code Online (Sandbox Code Playgroud)
它工作得很好.顺便说一句,我有很多其他有效的关系.只是这一个没有.
其他一些事情:1)我的核心数据对象模型看起来很好,但这是我在Xcode 4下添加的第一个新实体2)我已经检查,重新检查并且盲目地查看我的自定义NSManagedObjects,但它们看起来罚款 - 声明动态,NSSet,没有冲突的setter/getters ......等等.
任何帮助或调试建议将不胜感激.谢谢!
我正在尝试使用UIVideoEditorController来编辑我的视频,但它似乎失去了我的视频分辨率.我的原始视频是720 x 1280
,但使用后UIVideoEditorController
,质量变为360 x 640
.
我试图设置videoQuality
成为UIImagePickerControllerQualityTypeHigh
或甚至UIImagePickerControllerQualityTypeIFrame1280x720
,但这没有帮助.
我在iPad上工作,这是我的代码:
self.editorController = [[[UIVideoEditorController alloc] init] autorelease];
self.editorController.videoPath = self.tempVideoPath;
self.editorController.delegate = self;
self.editorController.videoQuality = UIImagePickerControllerQualityTypeHigh;
CKLog(@"%d", self.editorController.videoQuality);
self.popOverController = [[[UIPopoverController alloc] initWithContentViewController:self.editorController] autorelease];
self.popOverController.delegate = self;
self.popOverController.popoverContentSize = CGSizeMake(700, 700);
[self.popOverController presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.videoView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Run Code Online (Sandbox Code Playgroud) 我正在尝试测量我的UITableView的滚动性能,在使用子视图和自己绘制视图之间.正如我们可能知道的滚动性能,有一些着名的文章(Tweetie,TableViewSuite,Glassy和Glassy2,它们帮助我们掌握了这项技术,所有这些都将指向同一点:当我们有很多子视图时,我们应该使用drawRect .
问题是我不知道如何在两种情况下对性能进行基准测试:使用子视图或绘图.绘图实际上比subview更难,所以很难说服每个人直接绘图.我正在尝试编写2个小样本并使用2种技术并对性能结果进行基准测试.我目前正在尝试这个,但它为这两种技术生成相同的结果:
NSDate *date = [NSDate date];
static NSString *CellIdentifier = @"CellIdentifier";
CustomDrawingTableViewCell *cell = (CustomDrawingTableViewCell *) [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomDrawingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
// Main Code is HERE
NSDate *date2 = [NSDate date];
NSLog(@"%f", [date2 timeIntervalSinceDate:date]);
return cell;
Run Code Online (Sandbox Code Playgroud)
我的手机有4张图片,1张文字
objective-c ×7
iphone ×6
avfoundation ×3
ios ×3
android ×2
debugging ×2
addressbook ×1
avplayer ×1
c ×1
contacts ×1
core-data ×1
currency ×1
favorites ×1
inverse ×1
localization ×1
mediacodec ×1
performance ×1
scroll ×1
testing ×1
uitableview ×1
xcode4 ×1