我试图以某种方式处理视频:
我查看了互联网和stackoverflow,并看到有一个来自苹果的代码示例,名为AVEditDemo,但我永远无法找到它.如果有人有这个例子,并愿意与我分享或有任何类似的例子,可以教我如何做上述2个工作,那将是非常好的.
我看到有像一些类似的问题这一个,但我很想有代码示例.这将有助于我快速前进.
例如,方法:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
Run Code Online (Sandbox Code Playgroud)
in UIResponder
有一个NSSet* touches
参数.
在方法本身中,如何确定touches
实际包含的对象类型?在这种情况下,它包含一组UITouch
.但我从在线阅读一些教程就知道了.
一般来说,我如何知道集合包含哪种对象?
我在ApplicationBar上有一个最喜欢的图标,当项目受欢迎时,我希望将其更改为黄色图像.这适用于黑暗主题,但当用户更改为白色主题时,它会一直变黑.实际上,颜色变为黄色约1秒,然后变为黑色.
我正在测试Windows Phone 7 Emulator,而不是用设备测试
我正试图在我的应用程序中进行自动对焦工作,在iPad2中进行测试.我的问题是,当我调用check方法时isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus
,它总是返回NO.但是,我可以点击其他相机应用程序在我的设备中
devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *tempDevice in devices) {
[tempDevice lockForConfiguration:nil];
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {
NSLog(@"Here");
}
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
NSLog(@"Here");
}
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeLocked]) {
NSLog(@"Here");
}
if ([tempDevice isFocusPointOfInterestSupported]) {
NSLog(@"Here");
}
[tempDevice unlockForConfiguration];
}
Run Code Online (Sandbox Code Playgroud) 我想得到当前日期(日,星期一和年).我发现C中有一些函数可以像ctime(获取时间字符串),localtime和gmtime那样执行.我尝试使用以下代码,但输出不同.我得到这个输出:
日期和时间是2010年4月20日星期二(这是正确的)
这一年是:110
这一年是:110.
有人知道为什么吗?
int main(int argc, char** argv)
{
time_t now;
if((now = time(NULL)) == (time_t)-1)
{
puts("Failure in getting time");
}
else {
printf("The date and time is: %s\n", ctime(&now));
printf("The year is: %ld\n", localtime(&now)->tm_year);
printf("The year is: %ld\n", gmtime(&now)->tm_year);
}
getchar();
}
Run Code Online (Sandbox Code Playgroud) 我很难理解NSAutoReleasePool的工作原理.
1)NSAutoReleasePool是单独跟踪每个分配还是依赖于变量?换句话说,这会泄漏内存还是释放?:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray* myObj = [NSObject alloc];
myObj = [NSObject alloc];
[pool release];
Run Code Online (Sandbox Code Playgroud)
2)为什么以下代码有效:
NSAutoreleasePool *pool1 = [[NSAutoreleasePool alloc] init];
NSArray* myObj = [NSObject alloc];
for(int i = 0; i < 100; i++) {
[myObj release];
myObj = [NSObject alloc];
}
[pool1 release];
Run Code Online (Sandbox Code Playgroud)
但以下给出了EXC_BAD_ACCESS [pool1 release]
:
NSAutoreleasePool *pool1 = [[NSAutoreleasePool alloc] init];
NSArray* myObj = [NSObject alloc];
NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];
for(int i = 0; i < 100; i++) {
[myObj …
Run Code Online (Sandbox Code Playgroud) 我的所有视图都有一个蓝色导航栏,但当我希望用户选择一张照片时,UIImagePicker是黑色的.我尝试使用UIBarStyleDefault将UIImagePickerController的导航栏设置为蓝色,但它对我不起作用,颜色仍为黑色.我尝试过其他UIBarStyle,如UIBarStyleBlack和UIBarStyleOpaque,但它不会改变选择器的导航栏.这是我的代码
// Let the user choose a new photo.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.navigationBar.barStyle = UIBarStyleDefault;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
Run Code Online (Sandbox Code Playgroud) 如何在iPhone的gmap中使用纬度 - 经度计算两个地方之间的距离?
在新的iOS4中,我们有快速的应用程序切换,当我们暂停应用程序时,一些数据仍然在内存和成本内存中.
所以,我只是想知道,与不使用内存相比,将数据留在内存中是否会更快地消耗任何电池寿命?知道编程应用程序使用更少的内存,以便整个iPhone电池更好,这将是一件好事
我只想知道更多关于内存和电池的信息,而不是有任何问题.
我有一个NSNumber通过第三方API传递,当我在索引上调用intValue时,我得到一个EXC_BAD_ACCESS错误:
-(CPFill *) barFillForBarPlot:(CPBarPlot *)barPlot recordIndex:(NSNumber *)index;
{
NSLog(@"bar index %i", index);
int value = [index intValue];
}
Run Code Online (Sandbox Code Playgroud)
我在调试器中得到的输出是:
条形指数0
条形指数1
程序接收信号:"EXC_BAD_ACCESS".
到底他妈发生了什么?
我注意到第一次调用该方法时,index是nil,但下次显然不是......
我怎么调试这个?!?!它是如此微不足道的事情,但我似乎无法解决它!
我创建了自己的类,由NSObject派生,这是我的代码:
-(void) parseRow:(NSDictionary*) dictionary {
NSArray* arName = [[dictionary valueForKey:displayname] componentsSeparatedByString:@"+"];
[self setDriverName:[arName objectAtIndex:0]];
[self setDriverSurname:[arName objectAtIndex:1]];
[arName release]; // this give problem!
}
Run Code Online (Sandbox Code Playgroud)
在我看来:
driverStats = [[DriverStats alloc] init];
// driverStats is declared in the header:
DriverStats* driverStats;
@property (nonatomic,retain) DriverStats* driverStats;
[driverStats parseRow:dictionary];
Run Code Online (Sandbox Code Playgroud)
如果我在我的类中添加[arName release],当我从parseRow方法退出时,我有EXC_BAD_ACCESS错误....但是它错了?我使用数组并在我发布之后...我认为错误将是如果我没有释放指针..或不?提前致谢
我想在ArrayList/NSMutableArray中存储几个套接字,但套接字的类型为int,NSMutableArray只接受对象(id).是否有其他数据类型可以用作套接字的容器?我不确定我会有多少条目,所以我希望数据容器就像一个ArrayList.
谢谢!
编辑:我已经尝试将套接字作为NSNumber发送,但是当我尝试使用套接字发送消息时,它无法正常工作并导致XCode崩溃.
我有一个非常奇怪的错误UIWebView
,我将一个非常简单的html加载到UIWebView
:
[self.webview loadHTMLString:@"<html><body><div id='hello'>hello world</div></body></html>" baseURL:nil];
然后拨打以下4行:
NSString *body = [self.webview stringByEvaluatingJavaScriptFromString:
@"document.getElementsByTagName('body')[0].outerHTML"];
NSString *helloValue = [self.webview stringByEvaluatingJavaScriptFromString:
@"document.getElementByID('hello').value"];
NSString *helloOuter = [self.webview stringByEvaluatingJavaScriptFromString:
@"document.getElementByID('hello').outerHTML"];
NSString *helloInner = [self.webview stringByEvaluatingJavaScriptFromString:
@"document.getElementByID('hello').innerHTML"];
NSString *helloElement = [self.webview stringByEvaluatingJavaScriptFromString:
@"document.getElementByID('hello')"];
Run Code Online (Sandbox Code Playgroud)
只有第一行,使用getElementsByTagName返回正确的body html,所有其他行只返回一个空字符串@"".我的代码有什么问题?我怎样才能得到div
那个有id的hello